Question: 3 (5.8) Explain how the example concurrent program that enforces mutual exclusion with testAndSet (Fig 5.13) could lead to indefinite postponement. Indicate why this would

 3 (5.8) Explain how the example concurrent program that enforces mutual

exclusion with testAndSet (Fig 5.13) could lead to indefinite postponement. Indicate why

this would nev- ertheless be highly unlikely. Under what circumstances would it

3 (5.8) Explain how the example concurrent program that enforces mutual exclusion with testAndSet (Fig 5.13) could lead to indefinite postponement. Indicate why this would nev- ertheless be highly unlikely. Under what circumstances would it be acceptable to use this mu- tual exclusion technique? Under what circumstances would it be completely unacceptable? 1 System 3 boolean occupiedfalse; 4 5 startThreads(); initialize and launch both threads 6 7 Thread Ti 9 void main() 10 boolean plMustWait = true; 12 13 14 15 16 17 18 19 20 21 while Idone) while (p1MustWait) testAndset( plMustWait, occupied ); // critical section code plMustWait -true; occupied = false ; 23 24 25 26 27 // end while 28 29 / end Thread T1 30 // code outside critical section 1 Thread T2 32 33 void main) 34 35 36 37 38 39 40 41 42 43 boolean p2MustWait-true; while !done) while p2MustWait) testAndset ( p2Mustwait, occupied ); // critical section code 45 46 47 48 49 50 51 52 p2MustWaittrue occupiedfalse; II code outside critical section l/ end while 53 end Thread T2 Figure 5.13|testAndSet instruction for mutual exclution 3 (5.8) Explain how the example concurrent program that enforces mutual exclusion with testAndSet (Fig 5.13) could lead to indefinite postponement. Indicate why this would nev- ertheless be highly unlikely. Under what circumstances would it be acceptable to use this mu- tual exclusion technique? Under what circumstances would it be completely unacceptable? 1 System 3 boolean occupiedfalse; 4 5 startThreads(); initialize and launch both threads 6 7 Thread Ti 9 void main() 10 boolean plMustWait = true; 12 13 14 15 16 17 18 19 20 21 while Idone) while (p1MustWait) testAndset( plMustWait, occupied ); // critical section code plMustWait -true; occupied = false ; 23 24 25 26 27 // end while 28 29 / end Thread T1 30 // code outside critical section 1 Thread T2 32 33 void main) 34 35 36 37 38 39 40 41 42 43 boolean p2MustWait-true; while !done) while p2MustWait) testAndset ( p2Mustwait, occupied ); // critical section code 45 46 47 48 49 50 51 52 p2MustWaittrue occupiedfalse; II code outside critical section l/ end while 53 end Thread T2 Figure 5.13|testAndSet instruction for mutual exclution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!