Description of problem: spt.sched_priority=5; x=pthread_setschedparam(pthread_self(),SCHED_FIFO,&spt); assert(x==0); x=pthread_create(&pt,NULL,p,(void *)1234); according to the man page the default "schedpolicy" is OTHER default "schedparam" is 0 and most importantly default "inheritsched" is EXPLICIT thus policy of pt should be OTHER and priority 0 instead policy is FIFO and priority is 5 The error induces a context switch on every create which is very undesirable for master:multiple-worker paradigms Version-Release number of selected component (if applicable): 2.3.3 stable How reproducible: Easy Steps to Reproduce: #include "pthread.h" #include <stdio.h> #include <assert.h> void *p(void *arg) { int i,x; struct sched_param spt={0}; x=pthread_getschedparam(pthread_self(),&i,&spt); assert(x==0); printf("p policy=%d priority=%d\n",i,spt.sched_priority); pthread_exit((void *)8765); return NULL; } int main(int argc, char* argv[]) { int i,x=0; pthread_t pt; void *out; struct sched_param spt={0}; x=pthread_getschedparam(pthread_self(),&i,&spt); assert(x==0); spt.sched_priority=5; x=pthread_setschedparam(pthread_self(),SCHED_FIFO,&spt); assert(x==0); x=pthread_create(&pt,NULL,p,(void *)1234); assert(x==0); x=pthread_join(pt,&out); assert(x==0); return 0; } Actual results: p policy=0 priority=5 Expected results: p policy=0 priority=0 Additional info: Must run as superuser to test.
The man page describes linuxthreads, not NPTL (linuxthreads is the default pthread library you link against and use its headers, while at runtime you by default use NPTL). NPTL defaults to PTHREAD_INHERIT_SCHED. I looked through the standard and I believe the default is implementation-defined, but am not 100% sure about this.
There is no default value demanded by the standard. Inheriting the value is faster in the implementation. Programs which wish to not use the parent thread's value can very easily call pthread_setinheritsched.
This is still a bug. The man page states that the default is not to inherit attributes. If you don't make the implementation and the man page agree, then you will continue to get bug reports. Thanks for wasting my time by not paying attention to perfectly valid bug reports.