Question

I'm confused about Operating System's Synchronization part. I do not understand Mutual Exclusion issue with using at Monitor and Semaphore. Is that difference from each other?

Clearly; Does have Mutual Exclusion any difference with using at Monitor and Semaphore? Or do the same rules apply with using Mutual Exclusion at Monitor and Semaphore?

Additional Note = This sentence is confused me. "Semaphores and Monitors are all designed for solving mutual exclusion problem on one or more CPUs that all have access to a common memory"

Also I read those articles = Monitor - Mutual Exclusion

Mutex vs Semaphore

Was it helpful?

Solution

Mutual exclusion is a requirement on the behaviour of multiple parallel processes that use shared memory. The sentence that confused you refers to this: common memory = shared memory.

The mutual exclusion requirement states that at most one process can be in its critical section at any given time (a critical section is a piece of program code that uses a specific resource residing in shared memory). The requirement does not say anything about how it can be achieved, only what has to be achieved.

Semaphores and monitors are devices with which mutual exclusion can be enforced, so they answer the "how" question. Both have to be used according to their own rules, but both can enforce mutual exclusion.

Hope this helps.

OTHER TIPS

Here is how you should be thinking of mutual exclusion.

Mutual exclusion is to arbitrate the access of critical section(shared code among different threads) such that only one thread is allowed to execute the critical section at any time.There are multiple ways through which you can ensure mutual exclusion that includes the use of semaphore, mutex and monitors.It does not make any difference which mechanism you use for ensuring mutual exclusion whether semaphore or montior,The only difference is between the semaphore and monitor.semaphore are are genrally provide by os(although you can create your own) and monitors are programming language construct for providing mutual exclusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top