os5-1_con.ppt - Operating Systems Classical Problems of Concurrency A Frank P Weisberg Introduction to Concurrency \u2022 \u2022 \u2022 \u2022 \u2022 2 Classical

os5-1_con.ppt - Operating Systems Classical Problems of...

This preview shows page 1 - 10 out of 28 pages.

A. Frank - P. Weisberg Operating Systems Classical Problems of Concurrency
Image of page 1
2 A. Frank - P. Weisberg Introduction to Concurrency Classical Problems of Concurrency Critical Regions Monitors Inter-Process Communication (IPC) Communications in Client-Server Systems
Image of page 2
3 A. Frank - P. Weisberg Classical Problems of Concurrency There are many of them – let’s briefly see three famous problems: 1. P/C Bounded-Buffer 2. Readers and Writers 3. Dining-Philosophers
Image of page 3
4 A. Frank - P. Weisberg Reminder: P/C problem with race condition
Image of page 4
5 A. Frank - P. Weisberg P/C Bounded-Buffer Problem We need 3 semaphores: 1. A semaphore mutex (initialized to 1) to have mutual exclusion on buffer access. 2. A semaphore full (initialized to 0) to synchronize producer and consumer on the number of consumable items. 3. A semaphore empty (initialized to n) to synchronize producer and consumer on the number of empty spaces.
Image of page 5
6 A. Frank - P. Weisberg Bounded-Buffer – Semaphores Shared data semaphore full, empty, mutex; Initially: full = 0, empty = n, mutex = 1
Image of page 6
7 A. Frank - P. Weisberg Bounded-Buffer – Producer Process do { produce an item in nextp wait(empty); wait(mutex); add nextp to buffer signal(mutex); signal(full); } while (TRUE);
Image of page 7
8 A. Frank - P. Weisberg Bounded-Buffer – Consumer Process do { wait(full) wait(mutex); remove an item from buffer to nextc signal(mutex); signal(empty); consume the item in nextc } while (TRUE);
Image of page 8
9 A. Frank - P. Weisberg Notes on P/C Bounded-Buffer Solution Remarks (from consumer point of view): Putting signal(empty) inside the CS of the consumer (instead of outside) has no effect since the producer must always wait for both semaphores before proceeding.
Image of page 9
Image of page 10

You've reached the end of your free preview.

Want to read all 28 pages?

  • Summer '18
  • Aileen
  • Dining philosophers problem, Concurrency, Sleeping barber problem, P. Weisberg, Readers-writers problem

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture