[En-Nut-Discussion] Feature Request 1572837: mutex API nesting level info
Matthias Ringwald
mringwal at inf.ethz.ch
Mon Jul 14 11:44:32 CEST 2008
Hi Przmek
On 13.07.2008, at 23:01, Przemek Rudy wrote:
> This is not for the debug. There is obviously no problem taking the
> mutex value directly, but accessing internal data structures is a hack
> in my opinion. On the other hand there is no big pain giving this
> value
> back with public API.
I completely agree with this statement but I'm still wondering if
checking
the recursive mutex is the right way. The POSIX.1 standard does not
provide
this option, so my gut feeling is that maybe there should be an even
more
clean solution than returning the locking level.
In my understanding, a mutex is used to protect access to a shared
object.
The recursive mutex allows a function/thread to successively lock
(assert ownership of) this mutex without checking whether it already
owns the mutex.
If you already protect the function with a mutex, you're save to use a
simple
int counter as your own locking count inside the function. Then you
neither
have to access internals of the mutex nor have to use "exotic" :) APIs.
Does this make sense in your case?
Cheers
Matthias
(Sorry for beeing picky but I'm C.S. PhD student... :)
> Hi,
> Sorry for the delay.
>
> The story with this mutex is pretty simple:
> There is a function that calls the mutex. This function can be called
> recursively. But only for the first nested call an additional action
> must be made. Thus the simplest way for this is to check the mutex
> value
> just after taking it.
More information about the En-Nut-Discussion
mailing list