Questions tagged [recursive-mutex]

A recursive mutex (reentrant mutex) is a mutex which may be locked multiple times by the same process or thread, without causing a deadlock.

A recursive mutex (reentrant mutex) is a mutex which may be locked multiple times by the same process or thread, without causing a deadlock.

See also:

41 questions
0
votes
0 answers

pthread_mutex, PTHREAD_MUTEX_RECURSIVE and memory-barrier

In https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 it is said that recursive mutexes need not to synchronize memory. In my understanding, they therefore do not need to establish a memory-barrier. Should I then use…
wimalopaan
  • 4,838
  • 1
  • 21
  • 39
0
votes
0 answers

When can mutex->__data.__nusers be 4294967295?

I have a core dump file where pthread_mutex_destroy() has returned an error, probably because in the pthread_mutex_t data structure the __nusers field is set to 4294967295 (0xFFFFFFFF). Here are the full values: mMutex = { __data = { …
oliver
  • 6,204
  • 9
  • 46
  • 50
0
votes
0 answers

Mutex deadlock in with lock owner set to 0 in both the process

I am using a recursive mutex which is defined in shared memory for synchronization between two processes. I am seeing a deadlock between two processes but when I debugged core file, I found out that neither process A nor process B is owning the…
0
votes
2 answers

pthread_recursive_mutex - assertion failed

I'm using ROS (Robot operating system) framework. If you are familiar with ROS, in my code, I'm not using activity servers. Plainly using publishers, subscribers and services. Unfortunately, I'm facing issue with pthread_recursive_mutex error. The…
Venkatavaradhan
  • 139
  • 4
  • 13
0
votes
2 answers

Can't initiate Recursive Mutex

I am trying to initiate a recursive mutex but unable to succeed. This is my code: void init_locks_and_conds() { int type; // TODO DELETE if (pthread_mutexattr_init(&dead_or_alive_attr)) {perror(""); exit(1);} else if…
Daniel
  • 198
  • 2
  • 14
0
votes
0 answers

Can a C++ thread pause and store its context to rent to another? (thread ID borrowing)

Can a C++ thread A suspend its execution by storing that "pause" P in an object that can then be used in another thread B to run a function F in thread A? B could use P to unlock a mutex owned by A. Or F could lock a recursive mutex that was already…
curiousguy
  • 8,038
  • 2
  • 40
  • 58
0
votes
2 answers

Can a thread call .WaitOne() of a Mutex more than once before calling .ReleaseMutex() and vice versa?

In my code, it would be convenient if my thread calls .WaitOne() more than once before calling .ReleaseMutex(). And vice versa: Calling .ReleaseMutex() a few times before restarting a loop which begins with call to .WaitOne(). Some operating…
Doug Null
  • 7,989
  • 15
  • 69
  • 148
0
votes
0 answers

Having multiple reader locks in a single thread

I have data coupled with a Lock = boost::shared_mutex. I am locking data access with reader locks ReadLock = boost::shared_lock and writer locks WriteLock = boost::unique_lock. Obviously, lots of readers may be reading the data at a…
Bill Kotsias
  • 3,258
  • 6
  • 33
  • 60
0
votes
1 answer

How to avoid recursive_mutex

I have a case of recursive_mutex which I'm trying to solve. Here is the piece of code which explains the problem. void OnConnectionDisconnected() { boost::lock_guard lock ( m_mutexConnectionSet ); …
user832096
  • 373
  • 1
  • 6
  • 15
0
votes
0 answers

My recursive mutex vs pthread_mutex_t (type: recursive) (repost, push)

I was wondering if I could make a recursive mutex type on my own with a PTHREAD_MUTEX_ERRORCHECK mutex, this is the result: typedef struct { pthread_mutex_t mutex; uint32_t deadlocks; } pthread_recursivemutex_t; int…
Marco
  • 7,007
  • 2
  • 19
  • 49
0
votes
2 answers

Is there a portable way to statically initialise a recursive mutex?

According to POSIX, I can statically initialise a mutex this way: pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; However, what if I want the mutex to be recursive? Mutexes are non-recursive be default and there's no way to supply mutex attributes…
Martin Sustrik
  • 783
  • 10
  • 22
1 2
3