Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

image text in transcribed

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

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

More Books

Students also viewed these Databases questions

Question

A motion is a formal request to the court.

Answered: 1 week ago

Question

3. Why do people create new things?

Answered: 1 week ago

Question

Does file slack accompany a file when it is emailed?

Answered: 1 week ago

Question

a. Describe the encounter. What made it intercultural?

Answered: 1 week ago