pthread_attr_setschedinherit()...
John Schmidt <[email protected]>
| Newsgroups | gmane.comp.lib.phil |
|---|---|
| Message-ID | <[email protected]> |
Let's try this again, hopefully it's complete!
Running example from "Programming with POSIX Threads" on RH 9.0 with
glibc-2.3.2-11.9 and libpthread-0.29.so, these calls set|update the
wrong fields in the pthread_attr_t, pthread_attr_setschedpolicy()
updates __schedpolicy correctly. Here's the gdb output:
152 status = pthread_attr_setschedparam (
153 &thread_attr, &thread_param);
...
159 status = pthread_attr_setinheritsched (
160 &thread_attr, PTHREAD_EXPLICIT_SCHED);
...
(gdb) print thread_attr
$11 = {__detachstate = 0, __schedpolicy = 2, __schedparam =
{__sched_priority = 0},
__inheritsched = 4096, __scope = 0, __guardsize = 0, __stackaddr_set =
0, __stackaddr = 0x0,
__stacksize = 0}
...
(gdb) print thread_param
$15 = {__sched_priority = 50}
...
152 status = pthread_attr_setschedparam (
(gdb) step
154 if (status != 0)
(gdb) print thread_attr
$16 = {__detachstate = 50, __schedpolicy = 2, __schedparam =
{__sched_priority = 0},
__inheritsched = 4096, __scope = 0, __guardsize = 0, __stackaddr_set =
0, __stackaddr = 0x0,
__stacksize = 0}
(gdb) print thread_param
$17 = {__sched_priority = 50}
...
(gdb) step
Creating thread at RR/50
159 status = pthread_attr_setinheritsched (
(gdb) step
161 if (status != 0)
(gdb) print thread_param
$18 = {__sched_priority = 50}
(gdb) print thread_attr
$19 = {__detachstate = 50, __schedpolicy = 2, __schedparam =
{__sched_priority = 2},
__inheritsched = 4096, __scope = 0, __guardsize = 0, __stackaddr_set =
0, __stackaddr = 0x0,
__stacksize = 0}
(gdb)
As you can see, pthread_attr_setschedparam() sets __detachstate to 50
instead of __schedparam.__sched_priority, and
pthread_attr_setinheritsched() sets __schedparam.__sched_priority to 2
instead of __inheritsched... only a few int fields off...
Compiled using -Xlinker -rpath /usr/lib -Xlinker -rpath /lib/tls
-Xlinker -rpath /lib -lpthread -lrt
Also, in order to compile in the latest nptl *.bz2 do I need to rebuild
glibc from the SRPMS?
John Schmidt
Compuware Corporation