Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time.

Similar presentations


Presentation on theme: "1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time."— Presentation transcript:

1 1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time

2 2 Critical Regions (1) Four conditions to provide mutual exclusion 1. No two processes simultaneously in critical region 2. No assumptions made about speeds or numbers of CPUs 3. No process running outside its critical region may block another process 4. No process must wait forever to enter its critical region

3 3 Critical Regions (2) Mutual exclusion using critical regions

4 4 Mutual Exclusion with Busy Waiting (1) Proposed solution to critical region problem (a) Process 0. (b) Process 1.

5 5 Mutual Exclusion with Busy Waiting (2) Peterson's solution for achieving mutual exclusion

6 6 Mutual Exclusion with Busy Waiting (3) Entering and leaving a critical region using the TSL instruction

7 7 Sleep and Wakeup Producer-consumer problem with fatal race condition

8 8 What is a Semaphore? A mechanism that provides concurrency among processes. Facilitates synchronization among processes. Usually implemented with a struct, including an int as well as other information fields, and a queue to ensure mutual exclusion to a shared resource. Requires two operations (functions): sleep() or down() wakeup() or up() A new type of variable that saves the number of pending wakeups.

9 9 Semaphores The producer-consumer problem using semaphores

10 10 Mutexes Implementation of mutex_lock and mutex_unlock


Download ppt "1 Interprocess Communication Race Conditions Two processes want to access shared memory at same time."

Similar presentations


Ads by Google