Lec08_notes - CMPSCI 377 Operating Systems Spring 2010...

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

View Full Document Right Arrow Icon
CMPSCI 377 Operating Systems Spring 2010 Lecture 8: February 11 Lecturer: Prashant Shenoy 8.1 Implementing Locks To implement a lock, the OS needs a way to ensure that a process will be able to run a critical section where it can access some shared data without another process modifying the data at the same time. No matter how an OS chooses to implement locks, it must have some hardware support. One way to implement locks is to disable interrupts , since interrupts are the only way that a CPU has to change what it is doing. Normally, a process in an operating system will continue running unless it either performs an I/O request or it is interrupted by the operating system through the use of an interrupt–for example because it’s scheduling time quantum has run out or due to some kind of exception. By disabling interrupts, we can ensure that a process will maintain control of the CPU and guarantee that only one process (the active one) will have access to the shared data. Disabling interrupts will prevent any external events from causing the process to lose control of the CPU. In addition, the OS must prevent internal events as well; this is typically done by preventing a process from initiating an IO request while in a critical section. Another option for implementing locks would be to make use of atomic operations operation (which usually correspond to an assembly instruction), is such that test&set(x) returns 1, if x=1; otherwise, if x=0, it returns 0 and sets x to 1. Each of these operations must be implemented atomically by
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.

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 / 3

Lec08_notes - CMPSCI 377 Operating Systems Spring 2010...

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