v3stanford.edu-Locks_and_Condition_Variables - Locks and...

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

View Full Document Right Arrow Icon
http://w w w .stanford.edu/~ouster/cgi-bin/cs140-w inter12/lecture.php?topic=locks January 11, 2012 Locks and Condition Variables Locks and Condition Variables Lecture Notes for CS 140 Winter 2012 John Ousterhout Readings for this topic from Operating System Concepts : Sections 6.5-6.8. Needed: higher-level synchronization mechanism that provides Mutual exclusion: easy to create critical sections Scheduling: block thread until some desired event occurs Locks Lock : an object that can only be owned by a single thread at any given time. Basic operations on a lock: acquire: mark the lock as owned by the current thread; if some other thread already owns the lock then first wait until the lock is free. Lock typically includes a queue to keep track of multiple waiting threads. release: mark the lock as free (it must currently be owned by the calling thread). Producer/consumer implementation with locks: Producers add characters to a buffer Consumers remove characters from the buffer Characters will be removed in the same order added
Background image of page 1

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

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

Page1 / 3

v3stanford.edu-Locks_and_Condition_Variables - Locks and...

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

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