in Operating System edited by
1,190 views
0 votes
0 votes
In a certain application, the initial value of a counting semaphore s is 10. The following operations were completed on the semaphore in the given order 5P, 20P, 2V, 18P, 5V, 10P, 1V. The new value of counting semaphore is  _____________ ?
in Operating System edited by
1.2k views

4 Comments

p() means wait means decrement

v() means signal means increment

initial value is 10

10-5-20+2-18+5-10+1 = -35
0
0

shouldn’t it be 1 ?

Given the initial value of semaphore s: 10

  1. 5P (decrement by 5):
    • Current value of semaphore s: 10 - 5 = 5
  2. 20P (decrement by 20):
    • Current value of semaphore s: 5 - 20 = -15 (constrained to 0, as semaphores cannot go below 0)
  3. 2V (increment by 2):
    • Current value of semaphore s: 0 + 2 = 2
  4. 18P (decrement by 18):
    • Current value of semaphore s: 2 - 18 = -16 (constrained to 0)
  5. 5V (increment by 5):
    • Current value of semaphore s: 0 + 5 = 5
  6. 10P (decrement by 10):
    • Current value of semaphore s: 5 - 10 = -5 (constrained to 0)
  7. 1V (increment by 1):
    • Current value of semaphore s: 0 + 1 = 1
0
0

 No, it is not a binary semaphore.

0
0
can you please help me with this ?

Let the base priority of a system be 130 and the nice value provided is -10. What is the time slice that the process gets in the O(1) scheduling algorithm?

if it should be 300 or 400.
0
0

1 Answer

1 vote
1 vote
Here operation $P$ decreases the value of counting semaphores, and operation $V$ increments the value of counting semaphores.

initial value of counting semaphore =$10$,

new value of CS after performing $5P,20P,2V,18P,5V10P,1V$ operations: $10-5-20+2-18+5-10+1=-35$

1 comment

can you please help me with this ?

Let the base priority of a system be 130 and the nice value provided is -10. What is the time slice that the process gets in the O(1) scheduling algorithm?

if it should be 300 or 400.
0
0

Related questions