Skip site navigation (1)Skip section navigation (2)
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>

next in thread | raw e-mail | index | archive | help

--=-mXQEIRE+PoCybYP1kCsc
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

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?

--=20
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Said Helvetica Narrow to Helvetica Bold: "Hey, you're just my type."

--=-mXQEIRE+PoCybYP1kCsc
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: 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?=

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (FreeBSD)

iD8DBQBExWbZntdYP8FOsoIRAihUAJ4uGq6E2DDBESoyK7KN/0pe+KQSdgCgy0ck
juLSaAHKBIxwnLac1SFqgtQ=
=90lF
-----END PGP SIGNATURE-----

--=-mXQEIRE+PoCybYP1kCsc--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1153787609.20641.47.camel>