Sent via Deja.com
http://www.deja.com/
> I wrote an application which deals with sockets. To avoid accept()'s
> blocking state, I choose to use the pthread library.
> It works fine except that , .... my process grows in memory, and about 1
> hour after I ran it, -> Segmentation Fault.
> So I'm wondering if that problem could originate from this: Sometimes,
> the same mutex is locked (or unlocked) two or more times. Here's my
> question:
> What happen if the same mutex is locked 2 or more times without being
> unlocked between each lock ?
The behavior of locking mutex twice is depending on the mutex you used.
Ususally OS provides several kinds of mutexes, fast, recursive, and error-
checking mutex.(Some OS may only provides fast mutex.) Locking fast mutex
twice in the same thread is a deadlock. Locking recursive mutex twice in
the same thread means you need unlok it twice. Locking erro-checking mutex
in the same thread will reurn immediately with an error. You had better
consult the manual in you system.
> N what if a mutex is unlocked several times without being lock between
> each ?
I do not know. But why do not you avoid that by right programming logic?
what do you think?
***************************************************
Rich Lee (Lie-Quan)
Lab for Scientific Computing
University of Notre Dame
Email : ll...@lsc.nd.edu
Tel : 219-631-3906 (Office)
HomePage: http://www.lsc.nd.edu/~llee1/
***************************************************