operating systems {week 10}

Download Operating Systems {week 10}

Post on 21-Feb-2016




0 download

Embed Size (px)


Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D. Operating Systems {week 10}. A need for synchronization (i). Without synchronization amongst processes (and threads), results are unpredictable. how do variables x and y become corrupted?. - PowerPoint PPT Presentation


Chapter 1: Information Technology

Operating Systems{week 10}Rensselaer Polytechnic InstituteCSCI-4210 Operating SystemsDavid Goldschmidt, Ph.D.A need for synchronization (i)Without synchronization amongst processes (and threads), results are unpredictable

how dovariables x and ybecome corrupted?A need for synchronization (ii)Processes compete for resourcesOnce obtained, the resource isfully dedicated to a processOften, mutual exclusion is requiredNo other process is allowed access to the resource

Processes cooperate with other processesShared resourcesSpecific ordering or sequencing of eventsall of this appliesto threads, too!Semaphores (i)A semaphore is a synchronization mechanismSemaphore S is a special integer variable

OS provides two atomic operations on S:wait(S) or P(S):wait for a resource to become availablesignal(S) or V(S):signal that were done using a resource

Semaphores (ii)The wait(S) operation decrementssemaphore S only when S is available

wait(S) { while ( S