os5-2_con.ppt - Operating Systems Concurrency Linguistic Constructs A Frank P Weisberg Introduction to Concurrency \u2022 \u2022 \u2022 \u2022 \u2022 2 Classical

os5-2_con.ppt - Operating Systems Concurrency Linguistic...

This preview shows page 1 - 15 out of 36 pages.

A. Frank - P. Weisberg Operating Systems Concurrency Linguistic Constructs
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 Critical Regions (1 ( High-level linguistic synchronization construct. A shared variable v of type T, is declared as: v: shared T Variable v accessed only inside statement region v when B do S where B is a Boolean expression. While statement S is being executed, no other process can access variable v. Can be implemented by semaphores.
Image of page 3
4 A. Frank - P. Weisberg Critical Regions (2 ( Regions referring to the same shared variable exclude each other in time. When a process tries to execute the region statement: 1. The Boolean expression B is evaluated. 2. If B is true, statement S is executed. 3. If it is false, the process is delayed until B becomes true and no other process is in the region associated with v .
Image of page 4
5 A. Frank - P. Weisberg Bounded Buffer – Critical Region Shared data: struct buffer { int pool[n]; int counter, in, out; }
Image of page 5
6 A. Frank - P. Weisberg Bounded Buffer – Producer Process Producer process inserts nextp into the shared buffer. region buffer when(counter < n) { pool[in] = nextp; in = (in+1) % n; counter++; }
Image of page 6
7 A. Frank - P. Weisberg Bounded Buffer – Consumer Process Consumer process removes an item from the shared buffer and puts it in nextc region buffer when (counter > 0) { nextc = pool[out]; out = (out+1) % n; counter--; }
Image of page 7
8 A. Frank - P. Weisberg Critical Regions Limitation
Image of page 8
9 A. Frank - P. Weisberg Monitors (1 ( A high-level abstraction that provides a convenient and effective mechanism for process synchronization. Abstract data type , internal variables only accessible by code within the procedure. Only one process active within monitor at a time. There are many kinds. But not powerful enough to model some synchronization schemes . Found in many concurrent programming languages: Concurrent Pascal, Modula-3, uC++, Java, ... Can be implemented by semaphores .
Image of page 9
10 A. Frank - P. Weisberg Monitors (2 ( Monitor is a software module containing: one or more procedures (operations) an initialization sequence local data variables. Characteristics: local variables accessible only by monitor’s procedures. a process enters the monitor by invoking one of it’s procedures. only one process can be in the monitor at any one time.
Image of page 10
11 A. Frank - P. Weisberg Monitor Layout monitor monitor-name { // shared variable declarations procedure P1 (…) { …. } procedure Pn (…) {……} Initialization code (…) { … } } }
Image of page 11
12 A. Frank - P. Weisberg Schematic View of a Monitor
Image of page 12
13 A. Frank - P. Weisberg Monitor Example
Image of page 13
14 A. Frank - P. Weisberg
Image of page 14
Image of page 15

You've reached the end of your free preview.

Want to read all 36 pages?

  • Summer '18
  • Aileen
  • monitor, Semaphore, P. Weisberg

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture