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 transcribed

image 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

Students also viewed these Databases questions

Question

Define the term "Leasing"

Answered: 1 week ago

Question

What do you mean by Dividend ?

Answered: 1 week ago

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago

Question

Discuss consumer-driven health plans.

Answered: 1 week ago