Using QT 3.1.1.
I am trying to create a mutex in linux that mimics the behaviour of Windows i.e. if we are in a mutex lock and we try and lock the mutex again from inside the thread this is allowed. I think this is called recursive mutexing and this stops dead-locking the application.
I have tried the following when creating my mutex to make it mimic the Windows mutex:
pthread_mutex_t *criticalSection = cs;
if (pthread_mutex_init(criticalSection, &attr) == 0)
and when trying to lock the mutex:
if (pthread_mutex_trylock(criticalSection) == 0)
// we have managed to lock the mutex
But to no avail. It still comes back saying the mutex is busy when I try and lock it a second time. The recursive setup must not be working.
Any ideas what I'm doing wrong?