fix pthread_create regression
PATCH 1/1 fix pthread_create regression
My rt-caps patch included an ugly regression for the posix skin:
pthread_create fails if the caller passes SCHED_FIFO + a priority > 0 in the thread attribute. It's observable via switchtest for instance. This patch should fix it.
Note that 2.3.x urgently needs this patch as well!
Jan
skins/posix/thread.c +4 -2
@@ -139,7 +139,7 @@ int __wrap_pthread_create(pthread_t *tidif (!attr) { policy =SCHED_OTHER ; - param.sched_priority =0 ; + iargs.prio =0 ; }else {pthread_attr_getinheritsched (attr, &inherit);if (inherit ==PTHREAD_EXPLICIT_SCHED ) {
@@ -149,12 +149,15 @@ int __wrap_pthread_create(pthread_t *tid/* inherit == PTHREAD_INHERIT_SCHED */ __wrap_pthread_getschedparam (pthread_self (), &policy, ¶m); + iargs.prio = param.sched_priority;/* Work around linuxthreads shortcoming: it doesn't believe that it could have RT power as non-root and fails the thread creation overeagerly. */ memcpy (&iattr, attr,sizeof (pthread_attr_t)); + param.sched_priority =0 ;pthread_attr_setschedpolicy (&iattr,SCHED_OTHER ); +pthread_attr_setschedparam (&iattr, ¶m); attr = &iattr; }
@@ -164,7 +167,6 @@ int __wrap_pthread_create(pthread_t *tid iargs.start = start; iargs.arg = arg; iargs.policy = policy; - iargs.prio = param.sched_priority; iargs.ret =EAGAIN ;__real_sem_init (&iargs.sync,0 ,0 );