guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Recursive mutexes?


From: Rob Browning
Subject: Re: Recursive mutexes?
Date: Sat, 26 Oct 2002 23:36:21 -0500
User-agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2 (i386-pc-linux-gnu)

Marius Vollmer <address@hidden> writes:

> I am confused by the libc docs: what is a "timed" mutex?  Is it
> recursive or not?

Good question -- I had wondered if the two things were orthogonal,
i.e. you could select create (mutex, RECURSIVE | TIMED), but from
looking at the docs it's not clear to me, but they don't look
orthogonal.  The timed mutex was actually news to me -- I hadn't
realized they'd added those.

(I think perhaps I've been thinking more of the older threads
 implementation which wasn't quite the same as posix.)

> I just checked a little test program and the default pthread mutexes
> seem to be recursive, on GNU/Linux.  "Fast" mutixes are not
> resursive but you have to ask for them.

Hmm.  Now I'm confused.  I'd read the libc docs and it had looked to
me like fast mutexes were the default (they used to be), but now I see
that the libc docs say that fast mutexes are the default in the
*LinuxThreads* implementation.  The libc docs unfortunately don't seem
to say much about when you would be using the LinuxThreads
implementation as opposed to a posix one.  (have to go poke around and
see what the deal is these days)

> No.  But what about having two sets of locking/unlocking functions:
> one that behaves recursivly, and one that doesn't?

You could do that.  I think perhaps the reason posix doesn't is
because the non-recursive ones may be more efficient on a given
platform, and some people are be watching every cycle.  If that's the
only issue, then we may not care.

>> Well you certainly could use a condition variable instead of a mutex
>> here, but I would suspect that in cases where you just want to wake
>> someone else up, a mutex others can unlock would be lighter weight.
>> With a condition variable you have to have both a mutex and the
>> condition variable.
>
> And for a good reason, no?

Not sure I follow.

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD




reply via email to

[Prev in Thread] Current Thread [Next in Thread]