Fix NetBSD thread scheduling problem.

Defining thread priority for SCHED_OTHER is implementation defined.
Some platforms like NetBSD cannot reassign it as they are dynamic.

<http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html>

Credit goes to <kamil@netbsd.org> and <riastradh@netbsd.org> for finding this
solution.
This commit is contained in:
Yuval Langer 2016-04-03 02:20:07 +03:00
parent 7a563ebb2c
commit 37a4a4075e

View File

@ -138,6 +138,10 @@ void zmq::thread_t::setSchedulingParameters(int priority_, int schedulingPolicy_
policy = schedulingPolicy_; policy = schedulingPolicy_;
} }
#ifdef __NetBSD__
if(policy == SCHED_OTHER) param.sched_priority = -1;
#endif
rc = pthread_setschedparam(descriptor, policy, &param); rc = pthread_setschedparam(descriptor, policy, &param);
posix_assert (rc); posix_assert (rc);
#endif #endif