On Windows there is a function called EnterCriticalSection. It will not block if the same thread calls it more than once. I want to do the same thing on Linux and was trying pthread_mutex_lock. But that does not check to see if it is the same thread and will still block if the same thread calls it twice (a deadlock).
Is there a pthread_mutex that will do the same thing as EnterCriticalSection?