CHAP5 - Concurrency: Mutual Exclusion and Synchronization...

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

View Full Document Right Arrow Icon
Concurrency: Mutual Exclusion and Synchronization Chapter 5
Background image of page 1

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

View Full DocumentRight Arrow Icon
Currency Communication among processes Sharing resources Synchronization of multiple processes Allocation of processor time
Background image of page 2
Concurrency Multiple applications Multiprogramming Structured application Application can be a set of concurrent processes Operating-system structure Operating system is a set of processes or threads
Background image of page 3

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

View Full DocumentRight Arrow Icon
Difficulties with Concurrency Sharing global resources Management of allocation of resources Programming errors difficult to locate
Background image of page 4
A Simple Example void echo() { chin = getchar(); chout = chin; putchar(chout); }
Background image of page 5

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

View Full DocumentRight Arrow Icon
A Simple Example Process P1 Process P2 . . in = getchar(); . . in = getchar(); chout = chin; chout = chin; putchar(chout); . . putchar(chout); . .
Background image of page 6
Operating System Concerns Keep track of active processes Allocate and deallocate resources Processor time Memory Files I/O devices Protect data and resources Result of process must be independent of the speed of execution of other concurrent processes
Background image of page 7

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

View Full DocumentRight Arrow Icon
Process Interaction Processes unaware of each other Processes indirectly aware of each other Process directly aware of each other
Background image of page 8
Competition Among Processes for Resources Mutual Exclusion Critical sections Only one program at a time is allowed in its critical section Example only one process at a time is allowed to send command to the printer Deadlock Starvation
Background image of page 9

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

View Full DocumentRight Arrow Icon
Cooperation Among Processes by Sharing Writing must be mutually exclusive Critical sections are used to provide data integrity
Background image of page 10
Cooperation Among Processes by Communication Messages are passes Mutual exclusion is not a control requirement Possible to have deadlock Each process waiting for a message from the other process Possible to have starvation Two processes sending message to each other while another process waits for a message
Background image of page 11

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

View Full DocumentRight Arrow Icon
Requirements for Mutual Exclusion Only one process at a time is allowed in the critical section for a resource A process that halts in its non-critical section must do so without interfering with other processes No deadlock or starvation
Background image of page 12
Requirements for Mutual Exclusion A process must not be delayed access to a critical section when there is no other process using it No assumptions are made about relative process speeds or number of processes A process remains inside its critical section for a finite time only
Background image of page 13

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

View Full DocumentRight Arrow Icon
First Attempt Busy Waiting Process P0: while(turn!=0) {}; CS turn:=1; RS Process P1: while(turn!=1){}; CS turn:=0; RS
Background image of page 14
First Attempt Drawbacks: Busy waiting Processes must strictly alternate If one process fails the other process is permanently blocked
Background image of page 15

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

View Full DocumentRight Arrow Icon
Each process can examine the other’s status but cannot alter it. Process P0:
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/25/2008 for the course CSE 410 taught by Professor Bonakdarpour during the Summer '08 term at Michigan State University.

Page1 / 80

CHAP5 - Concurrency: Mutual Exclusion and Synchronization...

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

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