Lecture18nFull - Click to edit Master subtitle style...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style 8/1/11 Lecture 18 COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00 – 6:00 PM Lecture 18 8/1/11 n Last time: ¨ Processor sharing among multiple threads n Today: 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 n Signals n Semaphores n Monitors n Thread coordination with a bounded buffer. ¨ WAIT ¨ NOTIFY ¨ AWAIT ¨ ADVANCE ¨ SEQUENCE ¨ TICKET n Next Time ¨ Scheduling Algorithms Lecture 18 – Tuesday March 29, 2011 Lecture 18 22 Lecture 18 8/1/11 Thread coordination n Critical section P code that accesses a shared resource n Race conditions o two or more threads access shared data and the result depends on the order in which the threads access the shared data. n Mutual exclusion x only one thread should execute a critical section at any one time. n Scheduling algorithms & decide which thread to choose when multiple threads are in a RUNNABLE state ¨ FIFO – first in first out ¨ LIFO – last in first out ¨ Priority scheduling ¨ EDF – earliest deadline first n Preemption ¶ ability to stop a running activity and start another one with a higher priority. n Side effects of thread coordination ¨ Deadlock ¨ Priority inversion • a lower priority activity is allowed to run before one with a higher priority Lecture 18 33 Lecture 18 8/1/11 Solutions to thread coordination problems must satisfy a set of conditions Lecture 18 44 1. Safety: The required condition will never be violated. 2. Liveness: The system should eventually progress irrespective of contention. 3. Freedom From Starvation: No process should be denied progress for ever. That is, every process should make progress in a ¡nite time. 4. Bounded Wait: Every process is assured of not more than a ¡xed number of overtakes by other processes in the system before it makes progress. 5. Fairness: dependent on the scheduling algorithm • FIFO: No process will ever overtake another process. • LRU: The process which received the service least recently gets the service next. For example for the mutual exclusion problem the solution should guarantee that: Safety & the mutual exclusion property is never violated Liveness ¢ a thread will access the shared resource in a ¡nite time Freedom for starvation & a thread will access the shared resource in a ¡nite time Bounded wait - a thread will access the shared resource at least after a ¡xed number of accesses by other threads. Lecture 18 8/1/11 Thread coordination problems n Dining philosophers n Critical section Lecture 18 55 Lecture 18 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...
View Full Document

This note was uploaded on 07/30/2011 for the course COP 4600 taught by Professor Montagne during the Spring '08 term at University of Central Florida.

Page1 / 36

Lecture18nFull - Click to edit Master subtitle style...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online