170 |
int Thread::SetSchedulingPriority() { |
int Thread::SetSchedulingPriority() { |
171 |
#if !defined(__APPLE__) |
#if !defined(__APPLE__) |
172 |
int policy; |
int policy; |
173 |
char* policyDescription = NULL; |
const char* policyDescription = NULL; |
174 |
if (isRealTime) { // becomes a RT thread |
if (isRealTime) { // becomes a RT thread |
175 |
policy = SCHED_FIFO; |
policy = SCHED_FIFO; |
176 |
policyDescription = "realtime"; |
policyDescription = "realtime"; |
181 |
// set selected scheduling policy and priority |
// set selected scheduling policy and priority |
182 |
struct sched_param schp; |
struct sched_param schp; |
183 |
memset(&schp, 0, sizeof(schp)); |
memset(&schp, 0, sizeof(schp)); |
184 |
if (this->PriorityMax == 1) { |
if (isRealTime) { // it is not possible to change priority for the SCHED_OTHER policy |
185 |
schp.sched_priority = sched_get_priority_max(policy) + this->PriorityDelta; |
if (this->PriorityMax == 1) { |
186 |
} |
schp.sched_priority = sched_get_priority_max(policy) + this->PriorityDelta; |
187 |
if (this->PriorityMax == -1) { |
} |
188 |
schp.sched_priority = sched_get_priority_min(policy) + this->PriorityDelta; |
if (this->PriorityMax == -1) { |
189 |
|
schp.sched_priority = sched_get_priority_min(policy) + this->PriorityDelta; |
190 |
|
} |
191 |
} |
} |
192 |
if (pthread_setschedparam(__thread_id, policy, &schp) != 0) { |
if (pthread_setschedparam(__thread_id, policy, &schp) != 0) { |
193 |
std::cerr << "Thread: WARNING, can't assign " |
std::cerr << "Thread: WARNING, can't assign " |