Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Reading and Analysis (total: 10 scores) 36. Read the following program A and program B, and point out which program (A or B) may deadlock.
Reading and Analysis (total: 10 scores) 36. Read the following program A and program B, and point out which program (A or B) may deadlock. Please explain why. Program A: var mutex, empty, full: psemaphore; i,j , goods:integer;buffer:array [0...n-1] of item ; procedure producer; begin procedure begin while true do while true do begin begin produce next product P (mutex); P (mutex); P(empty); goods: =buffer(j) buffer(i):=product; j:=(j+1)mod(n); i:=(i+1)mod(n);V (mutex) V (mutex); V (empty); V( full ); consume praduct end end end; end; begin seminitial (mutex.v, 1; empty.v, n; full.v, 0); i:=j:=0; cobegin producer; consumer ; coend end var mutex, empty, full: psemaphore; i,j , goods:integer;buffer:array [0...n-1] of item ; begin seminitial (mutex.v, 1; empty.v, n; full.v, 0); i:=j:=0; cobegin producer; consumer; coend end
Step 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