Search unanswered questions...
Enter a question here...

What is basic difference between semaphore and monitor in operating system?

[Edit]

Answer

The wait and signal operations on condition variables in a monitor are similar to P and V operations on counting semaphores. A wait statement can block a process's execution, while a signal statement can cause another process to be unblocked. However, there are some differences between them. When a process executes a P operation, it does not necessarily block that process because the counting semaphore may be greater than zero. In contrast, when a wait statement is executed, it always blocks the process. When a task executes a V operation on a semaphore, it either unblocks a task waiting on that semaphore or increments the semaphore counter if there is no task to unlock. On the other hand, if a process executes a signal statement when there is no other process to unblock, there is no effect on the condition variable.

Another difference between semaphores and monitors is that users awaken by a V operation can resume execution without delay. Contrarily, users awaken by a signal operation are restarted only when the monitor is unlocked.

In addition, a monitor solution is more structured than the one with semaphores because the data and procedures are encapsulated in a single module and that the mutual exclusion is provided automatically by the implementation.
(excerpted from http://ei.cs.vt.edu/~cs5204/sp99/monitor.html)

Answer

The wait and signal operations on condition variables in a monitor are similar to P and V operations on counting semaphores. A wait statement can block a process's execution, while a signal statement can cause another process to be unblocked. However, there are some differences between them. When a process executes a P operation, it does not necessarily block that process because the counting semaphore may be greater than zero. In contrast, when a wait statement is executed, it always blocks the process. When a task executes a V operation on a semaphore, it either unblocks a task waiting on that semaphore or increments the semaphore counter if there is no task to unlock. On the other hand, if a process executes a signal statement when there is no other process to unblock, there is no effect on the condition variable.

Another difference between semaphores and monitors is that users awaken by a V operation can resume execution without delay. Contrarily, users awaken by a signal operation are restarted only when the monitor is unlocked.

In addition, a monitor solution is more structured than the one with semaphores because the data and procedures are encapsulated in a single module and that the mutual exclusion is provided automatically by the implementation.
(excerpted from http://ei.cs.vt.edu/~cs5204/sp99/monitor.html)

Improve Answer Discuss the question "What is basic difference between semaphore and monitor in operating system?" Watch Question

First answer by ID1098632089. Last edit by ID1098632089. Question popularity: 16 [recommend question]

Research your answer:

Answers.com > Wiki Answers > Categories > Jobs and Education > Education > College Degrees > What is basic difference between semaphore and monitor in operating system?

Our contributors said this page should be displayed for the questions below. (Where do these come from)
If any of these are not a genuine rephrasing of the question, please help out and edit these alternates.
Operating system monitor?  Semaphore in operating system?  What is the system of semaphore?  What is monitor in operating system?  Difference between task and semaphore?  What is semaphore in operating systems?  Difference between semaphore mutexspinlock?  Explain basic functions of operating system?  Waht is a monitor compare it with a semaphore?  Difference between a spin lock and a semaphore?  What is difference between semaphore and monitor?  What is the difference betwee mutex and semaphore?  Difference between monitor and semaphore in Operating systems?  What are the basic difference between windows system and unix system?  How a TP Monitor manages memory and processor resources more effectively than a typical operating system?