Question

P(sem) and V(sem) operations on semaphores are executed atomically. What will be the outcome of not executing P(sem) atomical

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A wait(P(sem)) operation atomically decrements the value associated with a semaphore. If two wait operations are executed on a semaphore when its value is 1, if the two operations are not performed atomically, then it is possible that both operations might proceed to decrement the semaphore value, thereby violating mutual exclusion.

In following code there are two processes 0 and 1. They take turns executing their critical sections. Thus mutual exculusion is present

Process 0 while (true) { while (turn != 0); /* wait until own turn */ <<< critical section >>> turn = 1; //After critical section, providing turn to other process <<< code outside critical section >>> }

Process 1
while (true)

{

while (turn != 1); /* wait until own turn */

<<< critical section >>>

turn = 10; //After critical section, providing turn to other process

<<< code outside critical section >>>

}

Consider P0, a process that must be in the critical section 70% of the time, and another process, P1, that must be in the critical section 1% of the time. P1's infrequent use of the critical section will block P0 most of the time (Progress criteria violated)

Add a comment
Know the answer?
Add Answer to:
P(sem) and V(sem) operations on semaphores are executed atomically. What will be the outcome of not...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. When the scheduler overlooks a process that is runnable, this situation is called (A) Deadlock...

    1. When the scheduler overlooks a process that is runnable, this situation is called (A) Deadlock (B) Livelock (C) Race (D) Starvation (E) This situation cannot happen. 2. Which of the following condition will cause the final result depending on the order of execution of instructions? (A) Deadlock (B) Livelock (C) Mutual Exclusion (D) Race (E) Starvation 3. Which of the following is not a hardware approach to mutual exclusion? (A) Interrupt disabling (B) Compare and Swap instruction (C) Spin...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT