Lec08 - Computer Science Lecture 8, page 1 Computer Science...

Info iconThis preview shows pages 1–4. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Computer Science Lecture 8, page 1 Computer Science CS377: Operating Systems Last Class: Synchronization • Wrap-up on CPU scheduling – MLFQ and Lottery scheduling • Synchronization – Mutual exclusion – Critical sections • Example: Too Much Milk • Locks • Synchronization primitives are required to ensure that only one thread executes in a critical section at a time. Computer Science Lecture 8, page 2 Computer Science CS377: Operating Systems Today: Synchronization: Locks and Semaphores • More on hardware support for synchronization • Implementing locks using disabling interrupts, test&set and busy waiting • What are semaphores? – Semaphores are basically generalized locks. – Like locks, semaphores are a special type of variable that supports two atomic operations and offers elegant solutions to synchronization problems. – They were invented by Dijkstra in 1965. Computer Science Lecture 8, page 3 Computer Science CS377: Operating Systems Hardware Support for Synchronization • Implementing high level primitives requires low-level hardware support • What we have and what we want Concurrent programs Low-level atomic operations (hardware) load/store interrupt disable test&set High-level atomic operations (software) lock semaphore monitors send & receive Computer Science Lecture 8, page 4 Computer Science CS377: Operating Systems Implementing Locks By Disabling Interrupts • There are two ways the CPU scheduler gets control: – Internal Events: the thread does something to relinquish control (e.g., I/O). – External Events: interrupts (e.g., time slice) cause the scheduler to take control away from the running thread. • On uniprocessors, we can prevent the scheduler from getting control as follows: – Internal Events: prevent these by not requesting any I/O operations during a critical section. – External Events: prevent these by disabling interrupts (i.e., tell the hardware to delay handling any external events until after the thread is finished with the critical section) • Why not have the OS support Lock.Acquire() and Lock.Release as system calls? Computer Science Lecture 8, page 5 Computer Science CS377: Operating Systems Implementing Locks by Disabling Interrupts • For uniprocessors, we can disable interrupts for high-level primitives like locks, whose implementations are private to the kernel. • The kernel ensures that interrupts are not disabled forever, just like it already does during interrupt handling....
View Full Document

This note was uploaded on 09/30/2010 for the course CS 377 taught by Professor Corner during the Fall '08 term at UMass (Amherst).

Page1 / 11

Lec08 - Computer Science Lecture 8, page 1 Computer Science...

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

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