Difference Between Semaphore and Monitor in OS

Operating SystemNetworkComputers

In this post, we will understand the difference between semaphore and monitor in an operating system −

Semaphore

  • It is an integer variable.

  • The value of this integer variable tells about the number of shared resources that are available in the system.

  • When any process has access to the shared resources, it performs the ‘wait’ operation (using wait method) on the semaphore.

  • When a process releases the shared resources, it performs the ‘signal’ operation (using signal method) on the semaphore.

  • It doesn’t have condition variables.

Monitor

  • It is an abstract data type.

  • It contains shared variables.

  • It also contains a set of procedures that operate upon the shared variable.

  • When a process wishes to access the shared variables in the monitor, it has to do so using procedures.

  • It has condition variables.

raja
Published on 19-Apr-2021 06:20:25
Advertisements