What is semaphore in Operating System?

Asked 04-Apr-2022
Viewed 311 times

1 Answer


0

What is semaphore in Operating System?
  • A semaphore is a variable or abstract data type in computer science that is used to restrict access to a shared resource by several threads and avoid critical section problems in a concurrent system like a multitasking operating system. Synchronization primitives include semaphores. A trivial semaphore is a simple variable that is incremented, decremented, or toggled in response to programmer-defined criteria.
  • Semaphores are a valuable tool for preventing race circumstances, but their use does not guarantee that a programme will be free of these issues. Counting semaphores allow for any resource count, but binary semaphores are used to establish locks and are limited to the numbers 0 and 1 (or locked/unlocked, unavailable/available).


Read More: When does trashing occur in Operating System?