Chapter 6: Synchronization
|
|
- Eustace Chandler
- 5 years ago
- Views:
Transcription
1 Chapter 6: Synchronization
2 Module 6: Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization Examples Atomic Transactions 6.2 Silberschatz, Galvin and Gagne 2005
3 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes Suppose that we wanted to provide a solution to the consumer-producer problem that fills all the buffers. We can do so by having an integer count that keeps track of the number of full buffers. Initially, count is set to 0. It is incremented by the producer after it produces a new buffer and is decremented by the consumer after it consumes a buffer. 6.3 Silberschatz, Galvin and Gagne 2005
4 Producer while (true) /* produce an item and put in nextproduced while (count == BUFFER_SIZE) ; // do nothing buffer [in] = nextproduced; in = (in + 1) % BUFFER_SIZE; count++; } 6.4 Silberschatz, Galvin and Gagne 2005
5 Consumer while (1) { while (count == 0) ; // do nothing nextconsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; count--; /* consume the item in nextconsumed } 6.5 Silberschatz, Galvin and Gagne 2005
6 Race Condition count++ could be implemented as register1 = count register1 = register1 + 1 count = register1 count-- could be implemented as register2 = count register2 = register2-1 count = register2 6.6 Silberschatz, Galvin and Gagne 2005
7 Race Condition Consider this execution interleaving with count = 5 initially: S0: producer execute register1 = count {register1 = 5} S1: producer execute register1 = register1 + 1 {register1 = 6} S2: consumer execute register2 = count {register2 = 5} S3: consumer execute register2 = register2-1 {register2 = 4} S4: producer execute count = register1 {count = 6 } S5: consumer execute count = register2 {count = 4} 6.7 Silberschatz, Galvin and Gagne 2005
8 Race Condition Race condition: The situation where several processes access and manipulate shared data concurrently. The outcome of the execution depends on the particular order in which the access takes To prevent race conditions, concurrent processes must be synchronized. 6.8 Silberschatz, Galvin and Gagne 2005
9 The Critical-Section Problem n processes all competing to use some shared data Each process has a code segment, called critical section, in which the shared data is accessed. Problem ensure that when one process is executing in its critical section, no other process is allowed to execute in its critical section. 6.9 Silberschatz, Galvin and Gagne 2005
10 Solution to Critical-Section Problem A solution to the critical-section problem must satisfy the following three requirements: 1.Mutual Exclusion - If process P i is executing in its critical section, then no other processes can be executing in their critical sections 2.Progress - If no process is executing in its critical section and there exist some processes that wish to enter their critical section, then only those not in RS can participate the decision of the next, and this selection cannot be postponed indefinitely Silberschatz, Galvin and Gagne 2005
11 Solution to Critical-Section Problem 3. Bounded Waiting - A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted 6.11 Silberschatz, Galvin and Gagne 2005
12 General structure of a typical process Pi do { entry section critical section exit section reminder section } while (true); 6.12 Silberschatz, Galvin and Gagne 2005
13 Peterson s Solution Two process solution Assume that the LOAD and STORE instructions are atomic; that is, cannot be interrupted. The two processes share two variables: int turn; Boolean flag[2] The variable turn indicates whose turn it is to enter the critical section. The flag array is used to indicate if a process is ready to enter the critical section. flag[i] = true implies that process P i is ready! 6.13 Silberschatz, Galvin and Gagne 2005
14 Algorithm for Process Pi do { flag[i] = TRUE; turn = j; while ( flag[j] && turn == j); CRITICAL SECTION flag[i] = FALSE; REMAINDER SECTION } while (TRUE); 6.14 Silberschatz, Galvin and Gagne 2005
15 Algorithm 1 Shared variables: int turn; initially turn = 0 turn = i P i can enter its critical section Process P i do { while (turn!= i) ; critical section turn = j; reminder section } while (true); Satisfies mutual exclusion, but not progress Executing sequence: P i, P j, P i, P j, P i, P j, 6.15 Silberschatz, Galvin and Gagne 2005
16 Algorithm 2 Shared variables boolean flag[2]; initially flag [0] = flag [1] = false. flag [i] = true P i ready to enter its critical section Process P i do { flag[i] := true; while (flag[j]) ; critical section flag [i] = false; remainder section } while (1); Satisfies mutual exclusion, but not progress requirement Silberschatz, Galvin and Gagne 2005
17 Algorithm 2 May loop infinitely If changes the order to be while (flag[j]) ; flag[i] := true; then the condition of mutual exclusion will not hold Silberschatz, Galvin and Gagne 2005
18 Synchronization Hardware Many systems provide hardware support for critical section code Uniprocessors could disable interrupts Currently running code would execute without preemption Generally too inefficient on multiprocessor systems Operating systems using this not broadly scalable Modern machines provide special atomic hardware instructions Atomic = non-interruptable Either test memory word and set value Or swap contents of two memory words 6.18 Silberschatz, Galvin and Gagne 2005
19 TestAndndSet Instruction Definition: boolean TestAndSet (boolean *target) { } boolean rv = *target; *target = TRUE; return rv: 6.19 Silberschatz, Galvin and Gagne 2005
20 Solution using TestAndSet Shared boolean variable lock., initialized to false. Solution: do { while ( TestAndSet (&lock )) ; /* do nothing // critical section lock = FALSE; // remainder section } while ( TRUE); 6.20 Silberschatz, Galvin and Gagne 2005
21 Swap Instruction Definition: void Swap (boolean *a, boolean *b) { boolean temp = *a; *a = *b; *b = temp: } 6.21 Silberschatz, Galvin and Gagne 2005
22 Solution using Swap Shared Boolean variable lock initialized to FALSE; Each process has a local Boolean variable key. Solution: do { key = TRUE; while ( key == TRUE) Swap (&lock, &key ); // critical section lock = FALSE; // remainder section } while ( TRUE); 6.22 Silberschatz, Galvin and Gagne 2005
23 Bounded-waiting mutual exclusion with TestAndSet() The hardware-based solutions to the CS problem do not satisfy the bounded-waiting requirement Another algorithm using the Test-and-Set() instruction that satisfies all the CS requirement boolean waiting [n]; /* are initialized to false */ boolean lock; /* is initialized to false */ A process P i can enter its critical section only if either waiting[i]== false or key == false Silberschatz, Galvin and Gagne 2005
24 Do { waiting[i] = TRUE; key = TRUE; while (waiting[i] && key) key = TestAndSet(&lock); waiting[i] = FALSE; Critical Section; j = (i + 1) % n; while ((j!= i) &&!waiting[j]) j = (j +1) % n; if (j == i) lock = FALSE; else waiting[j] = FALSE; Remainder Section; } while (TRUE); 6.24 Silberschatz, Galvin and Gagne 2005
25 Semaphore Synchronization tool that does not require busy waiting Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() (test) and V() (increment) Less complicated 6.25 Silberschatz, Galvin and Gagne 2005
26 Semaphore Can only be accessed via two indivisible (atomic) operations wait (S) { } while S <= 0 ; // no-op (busy waiting) S--; signal (S) { } S++; 6.26 Silberschatz, Galvin and Gagne 2005
27 Semaphore as General Synchronization Tool Counting semaphore integer value can range over an unrestricted domain Binary semaphore integer value can range only between 0 and 1; can be simpler to implement Also known as mutex locks Can implement a counting semaphore S as a binary semaphore Provides mutual exclusion Semaphore S; // initialized to 1 wait (S); Critical Section signal (S); 6.27 Silberschatz, Galvin and Gagne 2005
28 A more complicated example: begin parbegin /*Initially, all semaphores a ~ g are 0*/ begin S1; signal(a); signal(b); end; a S 1 b begin wait(a); S 2 ; S 4 ; signal(c); signal(d); end; S 2 begin wait(b); S 3 ; signal(e); end; S 3 begin wait(c); S5; signal(f); end; begin wait(d); wait(e); S6; signal(g); end; c S 4 d e begin wait(f); wait(g); S 7 ; end; S 5 S 6 parend end f g S Silberschatz, Galvin and Gagne 2005
29 Semaphore Implementation Must guarantee that no two processes can execute wait () and signal () on the same semaphore at the same time Thus, implementation becomes the critical section problem where the wait and signal code are placed in the critical section. Could now have busy waiting in critical section implementation But implementation code is short Little busy waiting if critical section rarely occupied Note that applications may spend lots of time in critical sections and therefore this is not a good solution Silberschatz, Galvin and Gagne 2005
30 Semaphore Implementation The main disadvantage of mutual-exclusion solutions is busy waiting (wasting CPU cycles in the loops of enter section). The semaphore defined before also has the same problem. Thus, the type of semaphore is also call a spinlock ( spin while waiting for the lock). To overcome the need for busy waiting, we can modify the definition of P and V, using block and wakeup operations. And define a semaphore as a record typedef struct { int value; struct process *list; } semaphore; 6.30 Silberschatz, Galvin and Gagne 2005
31 Semaphore Implementation Semaphore operations now defined as wait(semaphore *S): S->value--; if (S->value < 0) { } signal(s): S->value++; add this process to S->list; block(); if (S->value >= 0) { } remove a process P from S-> list; wakeup(p); 6.31 Silberschatz, Galvin and Gagne 2005
32 Semaphore Implementation signal(s) and wait(s) should be atomic. This situation is a CS problem (no two processes can executed wait() and signal() on the same semaphore simultaneously). Solutions uniprocessor system: inhibit interrupts during the execution of signal and wait operations multiprocessor system: disable interrupt does not work here (using spinlocks to ensure that wait and signal are performed atomically) 6.32 Silberschatz, Galvin and Gagne 2005
33 Semaphore Implementation Note that busy waiting have not be completely eliminated. It is removed from the entry to the CSs of application programs. It is limited to CSs of signal and wait operations, which codes are short (<10 instructions). Thus, the CS is almost never occupied, and busy waiting occurs rarely, and only for a short time 6.33 Silberschatz, Galvin and Gagne 2005
34 Semaphore as a General Synchronization Tool Execute B in P j only after A executed in P i Use semaphore flag initialized to 0 Code: P i A signal(flag) P j wait(flag) B 6.34 Silberschatz, Galvin and Gagne 2005
35 Deadlock and Starvation Deadlock two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes Let S and Q be two semaphores initialized to 1 P 0 P 1 wait (S); wait (Q); wait (Q); wait (S); signal (S); signal (Q); signal (Q); signal (S); Starvation indefinite blocking. A process may never be removed from the semaphore queue in which it is suspended. Ex: a semaphore in LIFO order 6.35 Silberschatz, Galvin and Gagne 2005
36 Classical Problems of Synchronization Bounded-Buffer Problem Readers and Writers Problem Dining-Philosophers Problem The three problems are important, because they are examples for a large class of concurrency-control problems. used for testing nearly every newly proposed synchronization scheme. Semaphores are used for synchronization in our solutions Silberschatz, Galvin and Gagne 2005
37 Bounded-Buffer Problem buffer of size n producer consumer Shared data semaphore full, empty, mutex; Initially: full = 0, /* # of full slots empty = n, /* # of empty slots mutex = Silberschatz, Galvin and Gagne 2005
38 Bounded Buffer Problem (Cont.) The structure of the producer process do { // produce an item wait (empty); wait (mutex); // add the item to the buffer signal (mutex); signal (full); } while (true); 6.38 Silberschatz, Galvin and Gagne 2005
39 Bounded Buffer Problem (Cont.) The structure of the consumer process do { wait (full); wait (mutex); // remove an item from buffer signal (mutex); signal (empty); // consume the removed item } while (true); 6.39 Silberschatz, Galvin and Gagne 2005
40 Readers-Writers Problem A data set is shared among a number of concurrent processes Readers only read the data set; they do not perform any updates Writers can both read and write. Problem allow multiple readers to read at the same time. Only one single writer can access the shared data at the same time. Shared Data Data set Semaphore mutex initialized to 1. Semaphore wrt initialized to 1. Integer readcount initialized to Silberschatz, Galvin and Gagne 2005
41 Readers-Writers Problem Two variations (priorities of readers and writers) No reader will be kept waiting unless a writer has already obtained permission to use the shared object. (Thus, no reader should wait for other readers to finish because a writer is waiting.) Writers may starve Once a writer is ready, that writer performs its write as soon as possible. (Thus, if a writer is waiting to access the object, no new readers may start reading.) Readers may starve 6.41 Silberschatz, Galvin and Gagne 2005
42 Readers-Writers Problem The structure of a writer process do { wait (wrt) ; // writing is performed signal (wrt) ; } while (true) 6.42 Silberschatz, Galvin and Gagne 2005
43 Readers-Writers Problem The structure of a reader process do { wait (mutex) ; readcount ++ ; if (readercount == 1) wait (wrt) ; signal (mutex) // reading is performed wait (mutex) ; readcount - - ; if redacount == 0) signal (wrt) ; signal (mutex) ; } while (true) 6.43 Silberschatz, Galvin and Gagne 2005
44 Readers-Writers Problem If a writer is in the CS and n readers are waiting, then the first one is queued on wrt the other n-1 are queued on mutex When a writer executes signal(wrt), either the waiting readers or a single writer are resumed. The selection is made by the scheduler Silberschatz, Galvin and Gagne 2005
45 Dining-Philosophers Problem Shared data Bowl of rice (data set) Semaphore chopstick [5] initialized to Silberschatz, Galvin and Gagne 2005
46 Dining-Philosophers Problem (Cont.) The structure of Philosopher i: Do { wait ( chopstick[i] ); wait ( chopstick[ (i + 1) % 5] ); // eat signal ( chopstick[i] ); signal (chopstick[ (i + 1) % 5] ); // think } while (true) ; (May Deadlock!) 6.46 Silberschatz, Galvin and Gagne 2005
47 Dining-Philosophers Problem Possible solutions to the deadlock problem Allow at most four philosophers to be sitting simultaneously at the table. Allow a philosopher to pick up her chopsticks only if both chopsticks are available (note that she must pick them up in a critical section). Use an asymmetric solution; that is, odd philosopher: left first, and then right an even philosopher: right first, and then left Besides deadlock, any satisfactory solution to the DPP problem must avoid the problem of starvation Silberschatz, Galvin and Gagne 2005
48 Problems with Semaphores Semaphores provide a convenient and effective mechanism for process synchronization. However, incorrect use may result in timing errors. signal(mutex);... critical section... wait(mutex); incorrect order (not mutual exclusive) forgotten wait(mutex);... critical section... wait(mutex);... critical section... wait(mutex); typing error (deadlock)... critical section... signal(mutex); 6.48 Silberschatz, Galvin and Gagne 2005
49 Monitor: A High-level Language Constructs A monitor is an approach to synchronize two or more processes that use a shared resource, usually a hardware device or a set of variables. With monitor-based concurrency, the compiler or interpreter transparently inserts locking and unlocking code to appropriately designated procedures, instead of the programmer having to access concurrency primitives explicitly Silberschatz, Galvin and Gagne 2005
50 Monitor: A High-level Language Constructs The representation of a monitor type consists of declarations of variables whose values define the state of an instance of the type procedures or functions that implement operations on the type. A procedure within a monitor can access only variables defined in the monitor and the formal parameters. The local variables of a monitor can be used only by the local procedures. The monitor construct ensures that only one process at a time can be active within the monitor Silberschatz, Galvin and Gagne 2005
51 Monitors High-level synchronization construct that allows the safe sharing of an abstract data type among concurrent processes. monitor monitor-name { // shared variable declarations } procedure body P1 ( ) {... } procedure body P2 ( ) {... } procedure body Pn ( ) {... } { initialization code } 6.51 Silberschatz, Galvin and Gagne 2005
52 Monitors condition variables To avoid entering a busy waiting state, processes must be able to signal each other about events of interest. Monitors provide this capability through condition variables. When a monitor function requires a particular condition to be true before it can proceed, it waits on an associated condition variable. By waiting, it gives up the lock and is removed from the set of runable processes. Any process that subsequently causes the condition to be true may then use the condition variable to notify a process waiting for the condition. A process that has been notified regains the lock and can proceed Silberschatz, Galvin and Gagne 2005
53 Monitors condition variables To allow a process to wait within the monitor, a condition variable must be declared, as condition x, y; Condition variable can only be used with the operations wait and signal. The operation x.wait(); means that the process invoking this operation is suspended until another process invokes x.signal(); The x.signal operation resumes exactly one suspended process. If no process is suspended, then the signal operation has no effect Silberschatz, Galvin and Gagne 2005
54 Schematic view of a Monitor 6.54 Silberschatz, Galvin and Gagne 2005
55 Monitor with Condition Variables 6.55 Silberschatz, Galvin and Gagne 2005
56 Monitor With Condition Variables Suppose Q executes x.wait and P executes x.signal. Both P and Q are in the monitor, one must wait. Two possibilities for the implementation: (a) Signal and wait: P either waits Q leaves, or waits another condition (b) Signal and continue: Q either waits P leaves, or waits another condition Possibility (b) seems more reasonable However, if Q waits, the logical condition for which Q is waiting may no longer hold by the time Q is resumed. Concurrent Pascal (using a compromise) When P executes x.signal, it leaves immediately, and Q is resumed immediately Silberschatz, Galvin and Gagne 2005
57 Dining Philosophers Example (deadlock-free) monitor dp { enum {THINKING, HUNGRY, EATING} state[5]; condition self[5]; void pickup(int i) void putdown(int i) void test(int i) void init() { for (int i = 0; i < 5; i++) state[i] = THINKING; } } 6.57 Silberschatz, Galvin and Gagne 2005
58 void pickup(int i) { state[i] = HUNGRY; test[i]; if (state[i]!= EATING) self[i].wait(); } try to eat void putdown(int i) { state[i] = THINKING; /*allow neighbors to eat // test left and right neighbors left test((i+4) % 5); right test((i+1) % 5); } 6.58 Silberschatz, Galvin and Gagne 2005
59 (if it is hungry) void test(int i) { if ( (state[(i + 4) % 5]!= EATING) && (state[i] == HUNGRY) && (state[(i + 1) % 5]!= EATING)) { state[i] = EATING; self[i].signal(); } if P i is suspended, } try to let P i eat resume it if P i is not suspended, no effect 6.59 Silberschatz, Galvin and Gagne 2005
60 An illustration P 3 thinking P P 2 hungry 0 2 self[2].wait; 1 P 0 P 1 thinking dp.pickup(1) eating; This solution cannot solve starvation! dp.pushdown(1) test (0) ; test (2) ; if P 3 is not eating self[2].signal 6.60 Silberschatz, Galvin and Gagne 2005
61 Monitor Implementation Using Semaphores Variables: semaphore mutex; // (initially = 1) semaphore next; // (initially = 0) int next-count = 0; Each external procedure F will be replaced by body of F compiler wait(mutex); body of F; if next-count>0 then signal(next) signal(mutex); else Mutual exclusion within a monitor is ensured. wakeup a suspended process allow others to enter the monitor 6.61 Silberschatz, Galvin and Gagne 2005
62 Monitor Implementation Using Semaphores For each condition variable x, we have: semaphore x-sem; // (initially = 0) int x-count = 0; The operation x.wait can be implemented as: x-count++; if (next-count > 0) signal(next); else signal(mutex); wait(x-sem); o o x-count--; A signaling process must WAIT until the resumed process either leaves or waits. NEXT: the signaling processes may suspend themselves Silberschatz, Galvin and Gagne 2005
63 Monitor Implementation The operation x.signal can be implemented as: if (x-count > 0) { next-count++; signal(x-sem); wait(next); next-count--; } no effect, if no process is waiting wakeup a waiting process 6.63 Silberschatz, Galvin and Gagne 2005
64 Monitor ResourceAllocator { boolean busy; condition x; void acquire(int time) { if (busy) x.wait (time); busy = TRUE; } void release() { busy = FALSE; x.signal (); } R.acquire(t);. access the resource;. R.release(); } initialization_code() { busy = FALSE; } 6.64 Silberschatz, Galvin and Gagne 2005
65 Monitor ResourceAllocator Conditional-wait construct: x.wait(c); c integer expression evaluated when the wait operation is executed. value of c (a priority number) stored with the name of the process that is suspended. when x.signal is executed, process with smallest associated priority number is resumed next. Check two conditions to establish correctness of system: User processes must always make their calls on the monitor in a correct sequence. Must ensure that an uncooperative process does not ignore the mutual-exclusion gateway provided by the monitor, and try to access the shared resource directly, without using the access protocols Silberschatz, Galvin and Gagne 2005
66 Synchronization Examples Solaris Windows XP Linux Pthreads 6.66 Silberschatz, Galvin and Gagne 2005
67 Solaris Synchronization Implements a variety of locks to support multitasking, multithreading (including real-time threads), and multiprocessing Uses adaptive mutexes for efficiency when protecting data from short code segments Uses condition variables and readers-writers locks when longer sections of code need access to data Uses turnstiles to order the list of threads waiting to acquire either an adaptive mutex or readerwriter lock 6.67 Silberschatz, Galvin and Gagne 2005
68 Windows XP Synchronization Uses interrupt masks to protect access to global resources on uniprocessor systems Uses spinlocks on multiprocessor systems Also provides dispatcher objects which may act as either mutexes and semaphores Dispatcher objects may also provide events An event acts much like a condition variable 6.68 Silberschatz, Galvin and Gagne 2005
69 Linux Synchronization Linux: disables interrupts to implement short critical sections Linux provides: semaphores spin locks 6.69 Silberschatz, Galvin and Gagne 2005
70 Pthreads Synchronization Pthreads API is OS-independent It provides: mutex locks condition variables Non-portable extensions include: read-write locks spin locks 6.70 Silberschatz, Galvin and Gagne 2005
71 Serializability and Concurrency- Control Algorithms Serializability Locking protocol Timestamp-based protocols 6.71 Silberschatz, Galvin and Gagne 2005
72 Serializability serial schedule: A schedule where each transaction is executed atomically. Schedule A nonserial schedule: allow two transactions to overlap their execution. Schedule B T 0 T 1 T 0 T 1 read(a) write(a) read(b) write(b) read(a) write(a) read(b) write(b) read(a) write(a) read(b) write(b) read(a) write(a) read(b) write(b) 6.72 Silberschatz, Galvin and Gagne 2005
73 Serializability O i and O j conflict if they access the same data item and at least one of them is a write. Conflict serializable: A schedule S can be transformed into a serial schedule S by a series of swaps of nonconflicting operations. Schedule B Schedule A r(a) 1 w(a) 1 r(b) 0 w(b) 0 r(b) 0 w(b) 0 r(a) 1 w(a) 1 Swap the read(b) of T 0 with the write(a) of T 1 Swap the read(b) of T 0 with the read(a) of T 1 Swap the write(b) of T 0 with the write(a) of T 1 Swap the write(b) of T 0 with the read(a) of T 1 Schedule B will produce the same final state as well some serial schedule Silberschatz, Galvin and Gagne 2005
74 Locking Protocol One way to ensure serializability is to associate with each data item a lock, and require that each transaction follow a locking protocol that governs how locks are acquired and released. Two lock modes Shared: allows read but not write Exclusive: allows both read and write Two-phase locking protocol: requires that each transaction issue lock and unlock in two phases: growing and shrinking. The execution order between every pair of conflicting transactions is determined at execution time Silberschatz, Galvin and Gagne 2005
75 Locking Protocol growing phase: may obtain lock, but cannot release any lock. shrinking phase: may release lock, but cannot obtain any lock. Initially, a transaction is in the growing phase. The transaction acquires locks as needed. Once the transaction releases a lock, it enters the shrinking phase, and no more lock requests can be issued. The two-phase locking protocol ensures conflict serializability. It does not, however, ensure freedom from deadlock Silberschatz, Galvin and Gagne 2005
76 Timestamp-based Protocols Select the order among transactions in advance Timestamps could be System clock Logical counter Implementation W-timestamp(Q): denotes the largest timestamp of any transaction that executed write(q) successfully. R-timestamp(Q): denotes the largest timestamp of any transaction that executed read(q) successfully. These timestamps are updated whenever a new read(q) or write(q) instruction is executed Silberschatz, Galvin and Gagne 2005
77 Timestamp-based Protocols Timestamp-based protocols Suppose T i issues read(q): If TS(T i ) < W-timestamp(Q), [read a value of Q that was already overwritten] read(q) is rejected, and T i is rolled back. If TS(T i ) > W-timestamp(Q), read(q) is executed, and R -timestamp(q) is set to the maximum of R-timestamp(Q) and TS(T i ). Suppose T i issues write(q): If TS(T i ) < R-timestamp(Q), [the value of Q that is producing was needed previously and T i assumed that this value would never be produced] write(q) is rejected, and T i is rolled back. If TS(T i ) < W-timestamp(Q), [is attempting to write an obsolete value] write(q) is rejected, and T i is rolled back. Otherwise, write(q) is executed Silberschatz, Galvin and Gagne 2005
78 Timestamp-Based Protocols A transaction that is rolled back by the concurrency-control scheme as a results of the issuing of either a read or write is assigned a new timestamp and is restarted. TS(T 2 ) < TS(T 3 ) T 2 10:00 T 3 10:02 read(b) read(a) read(b) write(b) read(a) write(a) The timestamp-ordering protocol ensures conflict serializability. The protocol ensures freedom from deadlock because no transaction ever waits Silberschatz, Galvin and Gagne 2005
79 Homework 1, 3, 7, 9, 11, 13, 18 Term Project: Producer-Consumer Problem (Due: Dec. 31, 2007) 6.79 Silberschatz, Galvin and Gagne 2005
80 End of Chapter 6
81 Bakery Algorithm Critical section for n processes Before entering its critical section, process receives a number. Holder of the smallest number enters the critical section. If processes P i and P j receive the same number, if i < j, then P i is served first; else P j is served first. The numbering scheme always generates numbers in increasing order of enumeration; i.e., 1,2,3,3,3,3,4, Silberschatz, Galvin and Gagne 2005
82 Bakery Algorithm Notation lexicographical order (ticket #, process id #) (a, b) < (c, d) if a < c or if a = c and b < d max (a 0,, a n-1 ) Shared data boolean choosing[n]; int number[n]; initialized to false and 0, respectively Silberschatz, Galvin and Gagne 2005
83 Bakery Algorithm do { choosing[i] = true; number[i] = max(number[0], number[1],, number [n 1])+1; choosing[i] = false; for (j = 0; j < n; j++) { while (choosing[j]) ; /* Wait for the choosing of P j while ((number[j]!= 0) && (number[j],j) < number[i], i)) ; /* smallest first } critical section number[i] = 0; remainder section } while (1); 6.83 Silberschatz, Galvin and Gagne 2005
84 Bakery Algorithm Key for showing the correctness if P i in CS, all other P k has number[k] = 0, or (number[i], i) < (number[k], k) mutual exclusion: OK progress: OK (smallest first) bounded waiting: OK Note that processes enter their CSs in a FCFS basis How many times? n Silberschatz, Galvin and Gagne 2005
Chapter 6: Process Synchronization. Module 6: Process Synchronization
Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationChapter 6: Process Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationModule 6: Process Synchronization
Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization Examples Atomic
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Chapter 6: Synchronization 6.1 Background 6.2 The Critical-Section Problem 6.3 Peterson s Solution 6.4 Synchronization Hardware 6.5 Mutex Locks 6.6 Semaphores 6.7 Classic
More informationChapter 6: Synchronization. Chapter 6: Synchronization. 6.1 Background. Part Three - Process Coordination. Consumer. Producer. 6.
Part Three - Process Coordination Chapter 6: Synchronization 6.1 Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure
More informationProcess Synchronization
Chapter 7 Process Synchronization 1 Chapter s Content Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors 2 Background
More informationChapter 7: Process Synchronization. Background. Illustration
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationChapter 7: Process Synchronization. Background
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationLesson 6: Process Synchronization
Lesson 6: Process Synchronization Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization
More informationSynchronization Principles
Synchronization Principles Gordon College Stephen Brinton The Problem with Concurrency Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms
More informationModule 6: Process Synchronization
Module 6: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization in Solaris
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Operating System Concepts 9th Edition Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationCHAPTER 6: PROCESS SYNCHRONIZATION
CHAPTER 6: PROCESS SYNCHRONIZATION The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. TOPICS Background
More informationChapter 6: Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Synchronization, Silberschatz, Galvin and Gagne 2009 Outline Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationChapter 6 Synchronization
Chapter 6 Synchronization Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 Outline Background The Critical-Section
More informationChapter 7: Process Synchronization!
Chapter 7: Process Synchronization Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Monitors 7.1 Background Concurrent access to shared
More informationModule 6: Process Synchronization. Operating System Concepts with Java 8 th Edition
Module 6: Process Synchronization 6.1 Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationChapter 5: Process Synchronization. Operating System Concepts Essentials 2 nd Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationProcess Synchronization
Process Synchronization Chapter 6 2015 Prof. Amr El-Kadi Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013! Chapter 5: Process Synchronization Background" The Critical-Section Problem" Petersons Solution" Synchronization Hardware" Mutex
More informationChapter 6: Process Synchronization
Module 6: Process Synchronization Chapter 6: Process Synchronization Background! The Critical-Section Problem! Peterson s Solution! Synchronization Hardware! Semaphores! Classic Problems of Synchronization!
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationProcess Synchronization
CSC 4103 - Operating Systems Spring 2007 Lecture - VI Process Synchronization Tevfik Koşar Louisiana State University February 6 th, 2007 1 Roadmap Process Synchronization The Critical-Section Problem
More informationProcess Synchronization
Process Synchronization Daniel Mosse (Slides are from Silberschatz, Galvin and Gagne 2013 and Sherif Khattab) Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution
More informationProcess Synchronization
TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Process Synchronization [SGG7] Chapter 6 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin
More informationBackground. Module 6: Process Synchronization. Bounded-Buffer (Cont.) Bounded-Buffer. Background
Module 6: Process Synchronization Background Background The Critical-Section Problem Synchronization Hardware Semaphores Classical Problems of Synchronization Critical Regions Monitors Synchronization
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Chapter 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks Semaphores Classic Problems of Synchronization
More informationLecture 3: Synchronization & Deadlocks
Lecture 3: Synchronization & Deadlocks Background Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization
More informationProcess Synchronization
CS307 Process Synchronization Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Background Concurrent access to shared data may result in data inconsistency
More informationChapter 5: Process Synchronization
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationChapter 6: Process Synchronization. Operating System Concepts 9 th Edit9on
Chapter 6: Process Synchronization Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Objectives To present the concept of process synchronization. To introduce the critical-section
More informationProcess Synchronization. CISC3595, Spring 2015 Dr. Zhang
Process Synchronization CISC3595, Spring 2015 Dr. Zhang 1 Concurrency OS supports multi-programming In single-processor system, processes are interleaved in time In multiple-process system, processes execution
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Chapter 5: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Mutex Locks
More informationOperating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy
Operating Systems Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. AL-AZHAR University Website : eaymanelshenawy.wordpress.com Email : eaymanelshenawy@yahoo.com Reference
More informationProcess Coordination
Process Coordination Why is it needed? Processes may need to share data More than one process reading/writing the same data (a shared file, a database record, ) Output of one process being used by another
More informationChapter 7 Process Synchronization
Contents 1. Introduction 2. Computer-System Structures 3. Operating-System Structures 4. Processes 5. Threads 6. CPU Scheduling 7. Process Synchronization 8. Deadlocks 9. Memory Management 10. Virtual
More informationChapter 6: Process Synchronization. Operating System Concepts 8 th Edition,
Chapter 6: Process Synchronization, Silberschatz, Galvin and Gagne 2009 Module 6: Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores
More informationInterprocess Communication By: Kaushik Vaghani
Interprocess Communication By: Kaushik Vaghani Background Race Condition: A situation where several processes access and manipulate the same data concurrently and the outcome of execution depends on the
More informationCS420: Operating Systems. Process Synchronization
Process Synchronization James Moscola Department of Engineering & Computer Science York College of Pennsylvania Based on Operating System Concepts, 9th Edition by Silberschatz, Galvin, Gagne Background
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1018 L11 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel feedback queue:
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 11 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Multilevel Feedback Queue: Q0, Q1,
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 12 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ 2 Mutex vs Semaphore Mutex is binary,
More informationReal-Time Operating Systems M. 5. Process Synchronization
Real-Time Operating Systems M 5. Process Synchronization Notice The course material includes slides downloaded from: http://codex.cs.yale.edu/avi/os-book/ and (slides by Silberschatz, Galvin, and Gagne,
More informationCS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University
Frequently asked questions from the previous class survey CS 370: SYSTEM ARCHITECTURE & SOFTWARE [PROCESS SYNCHRONIZATION] Shrideep Pallickara Computer Science Colorado State University Semaphores From
More informationChapter 6 Process Synchronization
Chapter 6 Process Synchronization Cooperating Process process that can affect or be affected by other processes directly share a logical address space (threads) be allowed to share data via files or messages
More informationCSE Opera,ng System Principles
CSE 30341 Opera,ng System Principles Synchroniza2on Overview Background The Cri,cal-Sec,on Problem Peterson s Solu,on Synchroniza,on Hardware Mutex Locks Semaphores Classic Problems of Synchroniza,on Monitors
More informationMaximum CPU utilization obtained with multiprogramming. CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait
Basic Concepts Scheduling Criteria Scheduling Algorithms Multiple-Processor Scheduling Real-Time Scheduling Thread Scheduling Operating Systems Examples Java Thread Scheduling Algorithm Evaluation CPU
More informationCSE 4/521 Introduction to Operating Systems
CSE 4/521 Introduction to Operating Systems Lecture 7 Process Synchronization II (Classic Problems of Synchronization, Synchronization Examples) Summer 2018 Overview Objective: 1. To examine several classical
More informationSemaphore. Originally called P() and V() wait (S) { while S <= 0 ; // no-op S--; } signal (S) { S++; }
Semaphore Semaphore S integer variable Two standard operations modify S: wait() and signal() Originally called P() and V() Can only be accessed via two indivisible (atomic) operations wait (S) { while
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data may result in data inconsistency Multiple threads in a single process Maintaining data consistency requires mechanisms to ensure the orderly execution
More informationChapter 6: Process Synchronization
Chapter 6: Process Synchronization Objectives Introduce Concept of Critical-Section Problem Hardware and Software Solutions of Critical-Section Problem Concept of Atomic Transaction Operating Systems CS
More information$ %! 0,-./ + %/ 0"/ C (" &() + A &B' 7! .+ N!! O8K + 8 N. (Monitors) 3+!
"#! $ %! *+ &' & "-/ &+, :/!! &+ 8/!.!"!! > &, < &+ 7!! "-/ :/= +. :/= 0 0/ 7!@?+ C (" & + A &B' 7! G' 3/ 0"=' 7> H 0 4 0! &D E.! 0 n I"2 &+ % &B' 0!!! n 1 + counter J " &B' & K n
More informationIntroduction to Operating Systems
Introduction to Operating Systems Lecture 4: Process Synchronization MING GAO SE@ecnu (for course related communications) mgao@sei.ecnu.edu.cn Mar. 18, 2015 Outline 1 The synchronization problem 2 A roadmap
More informationConcurrency: Mutual Exclusion and
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationCS370 Operating Systems
CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 1019 L12 Synchronization Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ Critical section: shared
More informationProcess Co-ordination OPERATING SYSTEMS
OPERATING SYSTEMS Prescribed Text Book Operating System Principles, Seventh Edition By Abraham Silberschatz, Peter Baer Galvin and Greg Gagne 1 PROCESS - CONCEPT Processes executing concurrently in the
More informationSynchronization. Race Condition. The Critical-Section Problem Solution. The Synchronization Problem. Typical Process P i. Peterson s Solution
Race Condition Synchronization CSCI 315 Operating Systems Design Department of Computer Science A race occurs when the correctness of a program depends on one thread reaching point x in its control flow
More informationDept. of CSE, York Univ. 1
EECS 3221.3 Operating System Fundamentals No.5 Process Synchronization(1) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Background: cooperating processes with shared
More informationProcess Synchronization
Process Synchronization Mandar Mitra Indian Statistical Institute M. Mitra (ISI) Process Synchronization 1 / 28 Cooperating processes Reference: Section 4.4. Cooperating process: shares data with other
More informationEI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)
EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture) Dept. of Computer Science & Engineering Chentao Wu wuct@cs.sjtu.edu.cn Download lectures ftp://public.sjtu.edu.cn User:
More informationProcesses. Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra
Processes Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra Processes Process Concept Process Scheduling Operation on Processes Cooperating Processes Interprocess Communication Process Concept Early
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationUNIT II PROCESS MANAGEMENT 9
UNIT II PROCESS MANAGEMENT 9 Processes-Process Concept, Process Scheduling, Operations on Processes, Interprocess Communication; Threads- Overview, Multicore Programming, Multithreading Models; Windows
More informationLecture 5: Inter-process Communication and Synchronization
Lecture 5: Inter-process Communication and Synchronization Real-Time CPU Scheduling Periodic processes require the CPU at specified intervals (periods) p is the duration of the period d is the deadline
More informationChapter 5: Process Synchronization. Operating System Concepts 9 th Edition
Chapter 5: Process Synchronization Silberschatz, Galvin and Gagne 2013 Objectives To present the concept of process synchronization. To introduce the critical-section problem, whose solutions can be used
More informationIV. Process Synchronisation
IV. Process Synchronisation Operating Systems Stefan Klinger Database & Information Systems Group University of Konstanz Summer Term 2009 Background Multiprogramming Multiple processes are executed asynchronously.
More informationOperating Systems Antonio Vivace revision 4 Licensed under GPLv3
Operating Systems Antonio Vivace - 2016 revision 4 Licensed under GPLv3 Process Synchronization Background A cooperating process can share directly a logical address space (code, data) or share data through
More informationCS370 Operating Systems Midterm Review. Yashwant K Malaiya Spring 2019
CS370 Operating Systems Midterm Review Yashwant K Malaiya Spring 2019 1 1 Computer System Structures Computer System Operation Stack for calling functions (subroutines) I/O Structure: polling, interrupts,
More informationProcess Synchronization(2)
EECS 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University Semaphores Problems with the software solutions.
More informationProcess Synchronization(2)
CSE 3221.3 Operating System Fundamentals No.6 Process Synchronization(2) Prof. Hui Jiang Dept of Computer Science and Engineering York University Semaphores Problems with the software solutions. Not easy
More informationSynchronization. CS 475, Spring 2018 Concurrent & Distributed Systems
Synchronization CS 475, Spring 2018 Concurrent & Distributed Systems Review: Threads: Memory View code heap data files code heap data files stack stack stack stack m1 m1 a1 b1 m2 m2 a2 b2 m3 m3 a3 m4 m4
More information1. Motivation (Race Condition)
COSC4740-01 Operating Systems Design, Fall 2004, Byunggu Yu Chapter 6 Process Synchronization (textbook chapter 7) Concurrent access to shared data in the data section of a multi-thread process, in the
More informationBackground. The Critical-Section Problem Synchronisation Hardware Inefficient Spinning Semaphores Semaphore Examples Scheduling.
Background The Critical-Section Problem Background Race Conditions Solution Criteria to Critical-Section Problem Peterson s (Software) Solution Concurrent access to shared data may result in data inconsistency
More informationConcurrency: Mutual Exclusion and Synchronization
Concurrency: Mutual Exclusion and Synchronization 1 Needs of Processes Allocation of processor time Allocation and sharing resources Communication among processes Synchronization of multiple processes
More informationProcess Synchronization: Semaphores. CSSE 332 Operating Systems Rose-Hulman Institute of Technology
Process Synchronization: Semaphores CSSE 332 Operating Systems Rose-Hulman Institute of Technology Critical-section problem solution 1. Mutual Exclusion - If process Pi is executing in its critical section,
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date: 04/04/2018 Max Marks: 40 Subject & Code: Operating Systems 15CS64 Semester: VI (A & B) Name of the faculty: Mrs.Sharmila Banu.A Time: 8.30 am 10.00 am Answer any FIVE
More informationSynchronization for Concurrent Tasks
Synchronization for Concurrent Tasks Minsoo Ryu Department of Computer Science and Engineering 2 1 Race Condition and Critical Section Page X 2 Algorithmic Approaches Page X 3 Hardware Support Page X 4
More informationCOP 4225 Advanced Unix Programming. Synchronization. Chi Zhang
COP 4225 Advanced Unix Programming Synchronization Chi Zhang czhang@cs.fiu.edu 1 Cooperating Processes Independent process cannot affect or be affected by the execution of another process. Cooperating
More informationUNIT 2 Basic Concepts of CPU Scheduling. UNIT -02/Lecture 01
1 UNIT 2 Basic Concepts of CPU Scheduling UNIT -02/Lecture 01 Process Concept An operating system executes a variety of programs: **Batch system jobs **Time-shared systems user programs or tasks **Textbook
More informationProcess Management And Synchronization
Process Management And Synchronization In a single processor multiprogramming system the processor switches between the various jobs until to finish the execution of all jobs. These jobs will share the
More informationProcess Synchronization. Mehdi Kargahi School of ECE University of Tehran Spring 2008
Process Synchronization Mehdi Kargahi School of ECE University of Tehran Spring 2008 Producer-Consumer (Bounded Buffer) Producer Consumer Race Condition Producer Consumer Critical Sections Structure of
More informationRoadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - XI Deadlocks - II. Louisiana State University
CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Tevfik Ko!ar Louisiana State University September 29 th, 2009 1 Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers
More informationRoadmap. Bounded-Buffer Problem. Classical Problems of Synchronization. Bounded Buffer 1 Semaphore Soln. Bounded Buffer 1 Semaphore Soln. Tevfik Ko!
CSC 4103 - Operating Systems Fall 2009 Lecture - XI Deadlocks - II Roadmap Classic Problems of Synchronization Bounded Buffer Readers-Writers Dining Philosophers Sleeping Barber Deadlock Prevention Tevfik
More informationProcess Synchronization
Process Synchronization Reading: Silberschatz chapter 6 Additional Reading: Stallings chapter 5 EEL 358 1 Outline Concurrency Competing and Cooperating Processes The Critical-Section Problem Fundamental
More informationRoadmap. Readers-Writers Problem. Readers-Writers Problem. Readers-Writers Problem (Cont.) Dining Philosophers Problem.
CSE 421/521 - Operating Systems Fall 2011 Lecture - X Process Synchronization & Deadlocks Roadmap Classic Problems of Synchronization Readers and Writers Problem Dining-Philosophers Problem Sleeping Barber
More informationSynchronization Principles II
CSC 256/456: Operating Systems Synchronization Principles II John Criswell University of Rochester 1 Synchronization Issues Race conditions and the need for synchronization Critical Section Problem Mutual
More informationBackground. Old Producer Process Code. Improving the Bounded Buffer. Old Consumer Process Code
Old Producer Process Code Concurrent access to shared data may result in data inconsistency Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes Our
More informationUnit 1: Introduction
Unit 1: Introduction What is an Operating System? Objectives and Funcations Computer System Architecture OS Structure OS Operations Evolution of Operating System Distributed Systems Clustered System Real
More informationProcess Synchronization
Process Synchronization Organized By: Vinay Arora V.A. Disclaimer This is NOT A COPYRIGHT MATERIAL Content has been taken mainly from the following books: Operating Systems Concepts By Silberschatz & Galvin,
More informationProcess Synchronization
Process Synchronization Concurrent access to shared data in the data section of a multi-thread process, in the shared memory of multiple processes, or in a shared file Although every example in this chapter
More informationHigh-level Synchronization
Recap of Last Class High-level Synchronization CS 256/456 Dept. of Computer Science, University of Rochester Concurrent access to shared data may result in data inconsistency race condition. The Critical-Section
More informationQUESTION BANK. UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks)
QUESTION BANK DEPARTMENT: EEE SEMESTER VII SUBJECT CODE: CS2411 SUBJECT NAME: OS UNIT II: PROCESS SCHEDULING AND SYNCHRONIZATION PART A (2 Marks) 1. What is deadlock? (AUC NOV2010) A deadlock is a situation
More informationProcess Synchronization. studykorner.org
Process Synchronization Semaphore Implementation Must guarantee that no two processes can execute wait () and signal () on the same semaphore at the same time The main disadvantage of the semaphore definition
More informationSynchronization. CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10)
Synchronization CSE 2431: Introduction to Operating Systems Reading: Chapter 5, [OSC] (except Section 5.10) 1 Outline Critical region and mutual exclusion Mutual exclusion using busy waiting Sleep and
More informationOperating Systems. Synchronization Based on Ch. 5 of OS Concepts by SGG
Operating Systems Synchronization Based on Ch. 5 of OS Concepts by SGG Need to Synchronize We already saw that if we write on a shared data structure w/o synchronization bad things can happen. The parts
More informationProcess Synchronisation (contd.) Deadlock. Operating Systems. Spring CS5212
Operating Systems Spring 2009-2010 Outline Process Synchronisation (contd.) 1 Process Synchronisation (contd.) 2 Announcements Presentations: will be held on last teaching week during lectures make a 20-minute
More informationProf. Hui Jiang Dept of Computer Science and Engineering York University
0./ ' )-, ' ' # # 2 H; 2 7 E 7 2 $&% ( Prof. Hui Jiang ept of omputer Science and Engineering York University )+* Problems with the software solutions. Not easy to generalize to more complex synchronization
More information