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
2 A. Frank - P. Weisberg Introduction to Concurrency Classical Problems of Concurrency Critical Regions Monitors Inter-Process Communication (IPC) Communications in Client-Server Systems
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.
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 .
5 A. Frank - P. Weisberg Bounded Buffer – Critical Region Shared data: struct buffer { int pool[n]; int counter, in, out; }
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++; }
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--; }
8 A. Frank - P. Weisberg Critical Regions Limitation
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 .
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.
11 A. Frank - P. Weisberg Monitor Layout monitor monitor-name { // shared variable declarations procedure P1 (…) { …. } procedure Pn (…) {……} Initialization code (…) { … } } }
12 A. Frank - P. Weisberg Schematic View of a Monitor
13 A. Frank - P. Weisberg Monitor Example
14 A. Frank - P. Weisberg

#### You've reached the end of your free preview.

Want to read all 36 pages?

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