{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture19nFull

# Lecture19nFull - COP 4600 Operating Systems Spring 2011...

This preview shows pages 1–4. Sign up to view the full content.

Click to edit Master subtitle style 8/1/11 Lecture 19 COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Lecture 19 8/1/11 n Last time: n Conditions for thread coordination – Safety, Liveness, Bounded-Wait, Fairness n Critical sections – a solution to critical section problem n Locks and Before-or-After actions. Hardware support for locks n Deadlocks; Signals; Semaphores; Monitors n Today: n Solutions to HW5 n Thread coordination with a bounded buffer. ¨ WAIT ¨ NOTIFY ¨ AWAIT ¨ ADVANCE ¨ SEQUENCE ¨ TICKET n Scheduling Algorithms n Next Time ¨ Scheduling Algorithms ¨ Multilevel memories Lecture 19 – Thursday March 31, 2011
Lecture 19 8/1/11 A solution to critical section problem n Applies only to two threads Ti and Tj with i,j ={0,1} which share ¨ i nteger turn t if turn=i then it is the turn of Ti to enter the critical section ¨ boolean flag[2] t if flag[i]= TRUE then Ti is ready to enter the critical section n To enter the critical section thread Ti ¨ sets flag[i]= TRUE ¨ sets turn=j n If both threads want to enter then turn will end up with a value of either i or j and the corresponding thread will enter the critical section. n Ti enters the critical section - in other words leaves the while loop - only if either ¨ flag[j]= FALSE °Tj is not ready to enter or ¨ turn=i it is the turn of Ti to enter n The solution is correct ¨

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}