Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions