libpthread patch

Robert Watson rwatson at freebsd.org
Fri Apr 18 03:50:00 PDT 2003


On Fri, 18 Apr 2003, Terry Lambert wrote:

> You are allowed to recurse on a mutex in the kernel, because there's
> some depth to code paths that shouldn't be there, but it's easier to
> allow recursion than it is to correct the code. 

By default, mutexes are not permitted to be recursed, and recursing them
will cause a panic.  Recursion is only permitted if the MTX_RECURSE flag
is set at mutex initialization time, which is strongly discouraged.  There
are several mutex in the kernel where the flag is set, but I hope to see
the list remain small (and go down).  A quick grep of of kern shows four
classes of mutexes with MTX_RECURSE set (one is Giant), and 57 without
(approximately).  The IP stack locking, on the other hand, has four mutex
classes, of which two permit recursion (PCB locks).

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Network Associates Laboratories




More information about the freebsd-threads mailing list