thread starving
Pav Lucistnik
pav at FreeBSD.org
Tue Jul 25 00:33:34 UTC 2006
Hey team,
I have a program which basically does this:
- start timer_thread with pthread_create()
- set handler for sigalarm that collects some statistics
- set up itimer which will fire sigalarms once per second
- start up a scientific computation
timer_thread does basically this:
while (1) {
sleep(1);
communicate statistics with controller over network
}
Now the problem. On certain machines, sometimes, the timer_thread never
starts to execute. pthread_create() returns 0 (success), but it's never
scheduled. Possibly because the main thread is in CPU intensive loop,
never sleeps, never waits for i/o. If I put pthread_yield() into the
main thread just after the pthread_create(), it runs a bit of
timer_thread, but then stalls.
But sometimes it works as it should. And there are machines where this
always works.
Now the most odd part: attaching truss or gdb to the application
unstucks the timer_thread.
I'm currently observing this on a 6.0-STABLE and 6.1-RC boxes.
How can I help it?
--
Pav Lucistnik <pav at oook.cz>
<pav at FreeBSD.org>
Said Helvetica Narrow to Helvetica Bold: "Hey, you're just my type."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: Toto je =?UTF-8?Q?digit=C3=A1ln=C4=9B?=
=?ISO-8859-1?Q?_podepsan=E1?= =?UTF-8?Q?_=C4=8D=C3=A1st?=
=?ISO-8859-1?Q?_zpr=E1vy?=
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20060725/44dd0488/attachment.pgp
More information about the freebsd-threads
mailing list