the bitrig natano_pthread_schedpolicy branch has been created by natano.

it is 2 commits behind master, and 1 commit ahead.

commit 5907f0693f3217b70bab7437d8c8e2a055c7808a
diff: https://github.com/bitrig/bitrig/commit/5907f06
author: Martin Natano <[email protected]>
date: Sat Apr 18 20:49:29 2015 +0200

Initialize sched_policy to a valid value.

The sched_policy of struct pthread is not being initialized, which means
that, with the main thread (_initial_thread) being a static variable and
threads created with pthread_create() being allocated with calloc(), the
variable has a value of 0 (zero). But 0 is not a valid scheduling policy.
The valid scheduling policies are: SCHED_FIFO(1), SCHED_OTHER(2) and
SCHED_RR(3).

I found this problem while working on port of software that contains
code similar to the following:

int policy;
struct sched_param param;
n = pthread_getschedparam(t, &policy, &param);
if (n)
        err(1, "pthread_getschedparam");
/* fiddle with params */
n = pthread_setschedparam(t, policy, &param);
if (n)
        err(1, "pthread_setschedparam");

The code failed to execute successfully, because pthread_setschedparam()
(rightly) rejected a policy of 0 as being invalid.

M       lib/librthread/rthread.c

Reply via email to