Q61: Atomicity of semaphore operations

Question 61: What is true about up() and down() operations of semaphore?

  1. The operations up() and down() must have to be atomic.
  2. The operations up() and down() can be made atomic by using the hardware based solution like TSL.
  3. The semaphore variable is a user level variable, but can’t be accessed directly.
  4. Both options 1 and 2.

 

Solution: They have to be atomic otherwise there can be race conditions. Hence, the correct answer is option 4.