Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following code for processes P1, P2 and P3, which share three semaphores x, y and z each with 1 as initial value and

Consider the following code for processes P1, P2 and P3, which share three semaphores x, y and z each with 1 as initial value and three variables a, b and c. 
Code for P0: (1.1) wait(x); (1.2) a = a + 1; (1.3) wait(y); (1.4) b = b - a; (1.5) wait(z); (1.6) c = a + 2*b -c; (1.7) signal(z); (1.8) signal(y); (1.9) signal(x) Code for P1: (2.1) wait(y); (2.2) b = b*2; (2.3) wait(z); (2.4) c = c - b; (2.5) signal(y); (2.6) wait(x); (2.7) a = a + c; (2.8) signal(x); (2.9) signal(z) Code for P2: (2.1) wait(y); (2.2) b = b*2; (2.3) wait(z); (2.4) c = c - b; (2.5) signal(z); (2.6) signal(y); (2.7) wait(x); (2.8) a = a / 10; (2.9) signal(x) Question: A. If P0 and P1 run concurrently on a computer with only a single CPU, is it possible for these two processes to get into a deadlock? If so, show one execution sequence of the code that results in the deadlock, and show how to revise P1 only (P0 is not changed) to prevent deadlock. B. If P0 and P2 run concurrently on a computer with only a single CPU, is it possible for these two processes to get into a deadlock? If so, show one execution sequence of the code that results in the deadlock, and show how to revise P2 only (P0 is not changed) to prevent deadlock. 

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago