πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      What is a 'semaphore' in Operating

      Systems?
      A A network protocol for inter-system communication Correct Answer Incorrect Answer
      B A synchronization tool used to control access to shared resources Correct Answer Incorrect Answer
      C A type of memory allocation algorithm Correct Answer Incorrect Answer
      D A process scheduling priority indicator Correct Answer Incorrect Answer
      E A hardware interrupt signal sent to the CPU Correct Answer Incorrect Answer

      Solution

      A semaphore is an integer variable accessed only through two atomic operations i.e. wait (P/down: decrement, block if 0) and signal (V/up: increment, wake blocked process). Binary semaphore (0 or 1) is a mutex lock. Counting semaphore allows N concurrent accesses. It is used to solve classic problems such as Producer-Consumer, Readers-Writers and Dining Philosophers. A race condition occurs when two threads simultaneously access shared data. Semaphores prevent this in multi-threaded banking transaction processing.

      Practice Next

      Relevant for Exams:

      ask-question