Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Iwo processes PO and P 1 are trying to enter their critical sections using the shared variable lock ( boolean ) and the TestandSetLock instruction.

Iwo processes PO and P1 are trying to enter their critical sections using the shared variable lock (boolean) and the TestandSetLock instruction. Initially, lock is set to FALSE.
(i) What is the purpose of TestAndSet() instruction?
(ii) Now, if both processes P0 and P1 simultaneously execute TestAndSetLock(lock) instruction, what happens?
boolean Testandset (boolean *target){
boolean rv=** target;
*target = TRUE;
return rv;
}
Figure 5.3 The definition of the TestAndSet () instruction.
do {
while (TestAndSetLock (&lock))
; // do nothing
// critical section
lock = FALSE;
// remainder section
}while (TRUE) ;
Figure 5.4 Mutual-exclusion implementation with TestAndSet ().
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students explore these related Databases questions