I couldn’t find a definitive answer so this is the place.
Windows’ EnterCriticalSection acts in the way that I can lock it multiple times in the same thread, and I need to unlock it on the way out the exact number of times so it will get free.
What is the Linux equivalent?
Does pthread mutex acts in the same way? Or is it multiple locks, single unlock…
you can use pthread mutex in recursive mode, using attribute PTHREAD_MUTEX_RECURSIVE_NP.
Linux equivalent is described in this article (see “listing2. Equivalent Linux code”)
http://www.ibm.com/developerworks/linux/library/l-ipc2lin3/index.html.