Date: Tue, 25 Jul 2006 02:33:29 +0200 From: Pav Lucistnik <pav@FreeBSD.org> To: freebsd-threads@FreeBSD.org Subject: thread starving Message-ID: <1153787609.20641.47.camel@ikaros.oook.cz>
index | next in thread | raw e-mail
[-- Attachment #1 --]
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@oook.cz>
<pav@FreeBSD.org>
Said Helvetica Narrow to Helvetica Bold: "Hey, you're just my type."
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)
iD8DBQBExWbZntdYP8FOsoIRAihUAJ4uGq6E2DDBESoyK7KN/0pe+KQSdgCgy0ck
juLSaAHKBIxwnLac1SFqgtQ=
=90lF
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1153787609.20641.47.camel>
