thread scheduling at mutex unlock

Andriy Gapon avg at
Wed May 14 15:17:47 UTC 2008

I am trying the small attached program on FreeBSD 6.3 (amd64,
SCHED_4BSD) and 7-STABLE (i386, SCHED_ULE), both with libthr as threads
library and on both it produces "BROKEN" message.

I compile this program as follows:
cc sched_test.c -o sched_test -pthread

I believe that the behavior I observe is broken because: if thread #1
releases a mutex and then tries to re-acquire it while thread #2 was
already blocked waiting on that mutex, then thread #1 should be "queued"
after thread #2 in mutex waiter's list.

Is there any option (thread scheduler, etc) that I could try to achieve
"good" behavior?

P.S. I understand that all this is subject to (thread) scheduler policy,
but I think that what I expect is more reasonable, at least it is more
reasonable for my application.

Andriy Gapon

More information about the freebsd-threads mailing list