Mutex can only be released from the same thread that was waiting on it?

Is it true that a mutex can only be freed from the thread that is waiting for this mutex? If so, why does the mutex behave this way? So, why do we say that a mutex can work through several processes? What are called mutex and unnamed-mutex? I am really confused by this problem!

If I want to wait for mutex in a thread and pass it from another thread, what should I do?

+3
source share
4 answers

The mutual exclusion semaphore must be freed by the same thread that received it. The way they work: one thread gets a lock on the resource so that it can manipulate it, and then when it is finished, it releases this lock so that other threads can block it.

The whole point of the “mutual exclusion” bit is that a blocked thread has full power — only it can release this lock. This still allows the mutex to work with multiple threads, because it can belong to any of them throughout its life.

mutex , . , "" , .

, , , , - , .Net - .

+5

(= Mut -ual Ex) ) , , .

+1

- . paxdiablo. - , ! - OK, condvar-OK, monitor-OK, -OK, Event-OK, - .

Rgds,

0

, ( )

. , , , .

. ?

BR Daniel

0

All Articles