Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2nd image is textbook figure. Answer only if u know it is correct and complete. Problems 1. Read the explanation of Table 5.4 on textbook
2nd image is textbook figure. Answer only if u know it is correct and complete.
Problems 1. Read the explanation of Table 5.4 on textbook page 224 or the notes of slides page 65. First, understand the possible scenario that the consumer consumes an item from the buffer that does not exist. You don't need to explain it in the assignment. Then explain why "It would not do simply to move the conditional statement inside the critical section of the consumer because this could lead to deadlock The modified code that "move the conditional statement inside the critical section" is shown in Fig. 1. Show the scenario that causes deadlock. (30 points) program producereonnum Ent n binary semaphore a day void producer while (true) produce semwait append memsonale delay) semana vold consumen WEBday while tue WALEBO Lake & -semwalde delay SORA vo ALAN Pembe producer one Fig. 1 A modified version of binary semaphores solution with infinite outer produchy Consumen Oconsumer problem A Possible Scenario for the Binary Semaphores solution Producer Consumer S n 1 1 Delay 0 0 semwaits) 0 0 1 1 B 0 0 0 n++ 0 1 if (n=1) (semSignalB (delay)) semsignall(s) 5 Producer adds an item before Consumer checks the buffer The consumer is NOT forced to wait 1 1 semwaitB (delay) 0 1 1 0 0 gemwaitB(3) 1 1 0 8 --- 0 9 semSignalB (s) 1 0 O semwaitB (3) 0 0 0 10 11 n++ 0 0 1 1 0 1 if(n==1) (semSignalB (delay)) semSignalB(s) if (0) (semwaitB (delay)) semwaitB () 1 1 0 1 1 1 0 1 1 1 1 1 0 n-- 0 16 17 18 19 20 21 semSignalB (3) if (n==0) (semwaitB (delay) ) semwait (3) 1 1 0 elo 0 0 n- 0 Note: White areas represent the critical section controlled by semaphores -1 0 semsignalB (3) 1 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started