Please Show Steps :) Question 11 There are three cooperating processes. They all
ID: 3706593 • Letter: P
Question
Please Show Steps :)
Question 11 There are three cooperating processes. They all read data from the same input device. Each process, when it gets the input device, must read two consecutive data. (Hint: use mutual exclusion to achieve it). Using semaphores, what is the minimum number of semaphores that could be used to solve this situation. How many would be initialized to 0 and how many would be initialized to 1: Pl inpt(al.a2) P2: input (b1,b2) P3 nput(cl,c2) Print X) W-b2+c2 X-Z-Y+W O 7 initialized to 0 and 1 initialized to 1 O 1 initialized to 0 and 7 initialized to 1 O 5 initialized to 0 and 1 initialized to 1 O and 5 initialized to 1Explanation / Answer
11. ANSWER
semaphore s1,s2,s3,s4,s5 //all are false initially
P1: input(a1,a2)
s1 = true
waitTillTrue(s2,s3) //till both are true
Y=a1+c1
waitTillTrue(s5)
Print (X)
P2: input(b1,b2)
s2 = true
waitTillTrue(s1,s3)
W = b2 + c2
waitTillTrue(s4)
X = Z-Y+W
s5=true
P3: input(c1,c2)
s3 = true
waitTillTrue(s1,s2)
Z = a2+b1
s4=true
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.