$ %! 0,-./ + %/ 0"/ C (" &() + A &B' 7! .+ N!! O8K + 8 N. (Monitors) 3+!
|
|
- Jeffery McLaughlin
- 6 years ago
- Views:
Transcription
1 "#! $ %! *+ &' & "-/ &+, :/!! &+ 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 </ 7! + &B' &+!!!808 + J :.%+ B 0! L 0M.+ N!! O8K + 8 N #define BUFFER_SIZE 10 typedef struct {... item; item buffer[buffer_size]; int in = 0; int out = 0; int counter = 0; :A &B' :(" 7!@ : C 7!@ item nextproduced; item nextconsumed; while (1) { while (counter == BUFFER_SIZE) ; /* do nothing */ buffer[in] = nextproduced; in = (in + 1) % BUFFER_SIZE; counter++; while (1) { while (counter == 0) ; /* do nothing */ nextconsumed = buffer[out]; out = (out + 1) % BUFFER_SIZE; counter--; 1
2 &T Q0"L &+ + counter 8 counter++ Q0R. " > Q0"L &+ + > Q/R U S@ &T.!S@ Q0"L &V8!K0 :+ Q0"L : &+, :/ Q0R : : 3+7 I!U counter++ register1 = counter register1 = register1 1 counter = register1 counter- - register2 = counter register2 = register2 1 counter = register2 Q0"L &+ X C 8 (" 7!@ 8! W 3+7 Q0"!, :/ H 780 &+ 0 % &B' 8/. " > (interleave) W+ 3 Q0"L &+ : N Q0"! 7. 8 counter = 5 Y IG +.(counter = 5 :"[ &T ) " > 0+. N 8 producer: register1 = counter (register1 = 5) producer: register1 = register1 + 1 (register1 = 6) consumer: register2 = counter (register2 = 5) consumer: register2 = register2 1 (register2 = 4) producer: counter = register1 (counter = 6) consumer: counter = register2 (counter = 4) &! '( Q0"L &+ 7!@ :] 3E 0! &, [ &M+) ^ J 0 E 8 0! +! A &B'!! &+ 8/.! + 3@ &/ 7 4@ & 7!@ Q/R &+!! 0M!! "-/.!0! %)+ 8/ 7!@ + &M+) ^ W"> +. " <%/ *+ )*! *+ )*! *+ )*!,) '( 7!@!U & E N@ [ 0! *+ &' &.,+V0!! &+ +! + "-+!! &+ +! &!0! *+ &'. 7!@.!0! 0V 3E 0! 0! 7!@. V8 &, & : :/= *+ &' & *+ &'!08 " / %! 7!@!0! 0V *+ &'.!"!"K,U / _ & + *+ &' & + ' 0.!7!08E+ 0!8* 0B 8,@ H& >8! & >8!,U / 7!@ ` H,!"K *+ &' > I' 0! 7!@ V8.!"!"K *+ &'!08 %!,@ 8,)!"K *+ &' > I' 0! 7!@ ` W - % E H) *+ &' &+!808 B 7!@!U!8* Q0"L &+ " / *+ &' &+!808 + U+ 7!@.!" &K 1"U &+.. 2
3 *+ )*!,) '(!8* 0B.! + H I0 0 *+ &' &+!808 =M 7!@ V8 7 V *+ &' &+ 7!@!808 QU! + 5+ '..+ &!!">8,"K0! 7!@ &+!808 7"T [R > L 7 W0+ R + 7!@ &/! Y 3".!S@ 3@ E *+ &' > 37 0! S( H " 7!@ >,R 3,) 0+0! a & "W ` 3" /.,! *,) ' P 2 8 P 1 7!@ 8! + ^M 0 3E + & ' +.! A J 7 %/ + " 7!@ :. : 7!@ 0K entry section exit section reminder section while (1); A J.L :!0M Hturn b*l!r.!"!"k *+ &'!08 " P i 7!@ turn == i :P i 7!@ while (turn!= i) ; turn = j; reminder section while (1);.K 0,@ H 0V+ 0 & >8!,U / _ A J.,0! :!0M Hflag 8! ("+ &0E.!"!"K *+ &'!08 " P i 7!@ flag [i] == true :P i 7!@ flag[i] := true; while (flag[j]) ; flag [i] = false; while (1);.K 0,@ H 0V+ 0 & >8!,U / _ 3 - (** -) * n,) flag [i]:= true; turn = j; while (flag [j] and turn = j) ; flag [i] = false; while (1); "%( 7 :P i 7!@ 0. 3"R &+ " :++ H 0V+ 0 _ &.!"! 7!@ 8! *+ &' & + '.,0!!R. *+ &' &+!808 7 N@ 7!@ *+ &'!08 + &! 0!R :]" & 7!@.!" P i % E i < j W H,0! 0!R. P j 8 P i 7!@ 8! W.!"!"K *+ &'!08 P j & W8 (" d + 0!R &/!R (" < Q0"L : &+ " 7T?. & "/ +. :+ 1, 2, 3, 3, 4, 4, 4, 5, 3
4 * n,) ** - &, &J(?. % + ]"!/ 0"%( : 0!.!" I/R (7!@ & H0!!R)? O87 80.a = c && b < d 8 i = 0,, n 1 + & /)V &+ k boolean choosing[n]; int number[n]; a < c (a, b) < (c, d),!r max (a 0,, a n-1 ).k a i + &! :A J. "!0M L 8,0!!M +? &+ & 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]) ; while ((number[j]!= 0) && (number[j,j] < number[i,i])) ; number[i] = 0; while (1); *+ &' & & 0"! 7! + 3".! <%/ 0 7!@ " > S@ &T Q0"L &+ + S@ &T Q0"L &+ 0 &B' 7 &/. 0M :TestAndSet.!0M,0! &+ 0 3E 4# 8! &)M,0!. Y"R + S@ &T Q0"L &+ 0 J 8! 0M :Swap boolean TestAndSet(boolean &target) { boolean rv = target; tqrget = true; return rv; :TestAndSet :TestAndSet -3 7*8 19*.,0! 0M + lock ("+ J :A!! while (TestAndSet(lock)) ; lock = false; 7!@ :P i boolean lock; boolean waiting[n]; :Swap -3 7*8 19* :(,0! 0M +) A!! key = true; while (key == true) Swap(lock,key); lock = false; 7!@ :P i 4
5 63 *+ &' & 63 + ^M!0M 7 4@ &, b*l J.., +! +V signal 8 wait 0"! 8! 7! wait (S): while S 0 do no-op; S--; signal (S): S++; 63 4 *+ )*!,) 63 3 semaphore mutex; do { wait(mutex); signal(mutex); while (1); :(.!0M +) A!! 7!@ :P i typedef struct { int value; struct process *L; semaphore; :!" $U 7 Q0"L &+. 7 Q0"L &+ wakeup 8 block! Q/R 8! Y :+ $U.!08E 0! 1U,(' &+ 0 "K 7!@ > block.!w 7 0 P 1U 7!@ > wakeup (P) : $U Q0"L : & Q/R 5' wait(s): S.value--; if (S.value < 0) { add this process to S.L; block; %/ + "/R 0+ 3"R &+ 7 3".!! 7!@ 0! B Q/R 7 V /' P i 7!@ 0! A Q/R "K Y.!" > P j 7!@.! L 0M : + signal(s): S.value++; if (S.value <= 0) { remove a process P from S.L; wakeup(p); P i P j M M A wait(flag) signal(flag) B 5
6 +; 1! +; 1! Q0"L &+ ] 8! &!" &W [ &+ 1! 3/ 7 ^" + & )!K0 e"v8 B 3@ +.+ f 7!@ :+ L 0M + 8! Q 8 S Y & "/ + P 0 P 1 wait(s); wait(q); wait(q); wait(s); M M signal(s); signal(q); signal(q) signal(s); 7 7!@ - + LIFO < 7. Y,(' : 0!.! I% B 7!@ $L.+ N@ [*V, :/ 7!@ 0! 7!@ $L 7!,(' 0! :++.!" T [*V 8,)+ :+ &+ " & 63 & 63.0M 8! 8 0/ :!0!!">8 e" 8!,(' 0! 0!8*!M " &, b*l!r. 0/.! gk!"k &+.,. L 3E 0M &, b*l!r. 0M 8! 0M8! 7! + 0 0/. 3".! 7!@ :!! 0K binary-semaphore S1, S2; int C; :!0M S1 = 1; S2 = 0; C = initial value of S; wait operation wait(s1); C--; if (C < 0) { signal(s1); signal operation wait(s1); C ++; if (C <= 0) signal(s2); signal(s1); signal(s1); wait(s2); 43<,! *+ &' & 43<,! :7!@ %/. & & 0+ &+ N-+ : 0!!8* % &B' + C (" & )" 8 "K & C") 0"KSd & 6
7 semaphore full = 0, empty = n, mutex = 1; produce an item in nextp wait(empty); wait(mutex); add nextp to buffer signal(mutex); signal(full); while (1); :(!0M +) A!! :(" 7!@ wait(full) wait(mutex); remove an item from buffer to nextc signal(mutex); signal(empty); consume the item in nextc while (1); :(" 7!@!* *=!!* *=! semaphore mutex = 1, wrt = 1; int readcount = 0; wait(wrt); writing is performed signal(wrt); :(!0M +) A!! :)" 7!@ wait (mutex); readcount ++; if (readcount == 1) wait (wrt); signal (mutex); reading is performed wait (mutex); readcount --; if (readcount == 0) signal (wrt); signal (mutex); : "K 7!@ "!>6 =?@! "!>6 =?@! semaphore chopstick [5] = {1; :(!0M +) A!! wait (chopstick[i]) wait (chopstick[(i+1) % 5]) eat signal (chopstick[i]); signal (chopstick[(i+1) % 5]); think while (1); :< i C") 7!@ 7
8 *+ & *+ &' & *+ AB 8 wait >?,R0 <R 8 7,0!!,)+ :+ 8!! &+ 3/! signal,0! > : wait - signal!! &+ 3/! : signal - wait,)+ :+ : wait - wait 5+ b[ )" & + 0K 7! :!@ ' 0., 7!@ %/ + 5+ b[ 0K. *+ &M[ *+ & *+ & :!" 3R 7 Q0"L &+ T e" 7 v A J. v: shared T. B ), S@ 3 7 Q0R 0! v J &+! :(, ("+ J region v when B do S v J &+ " / %! 7!@ H!" > Q0R : V8. +! > 7 H e>0 A J. &+ &.,U / % 3/ H > 0 *+ &M[ Q0R "K 7!@. V B ("+ Q0R 0M.!" > Q0R H+,0! B W 0! %! 7!@ & 7 B 7!@ H+,0! B W.!",0! ++ B 0M 8 v &+ _"+ *+ &M[ C H(" & :& "/. :A!! struct buffer { int pool [n]; int count, in, out; ( ) *+ & region x when B do S 3 :! 0V A &B' 0! 0 nextp (" 7!@ region buffer when( count < n) { pool[in] = nextp; in:= (in+1) % n; count ++; :!0! + A &B' 7 0 & "/ C 7!@ region buffer when (count > 0) { nextc = pool[out]; out = (out+1) % n; count --; :+ gk 0 7 J x J &+ semaphore mutex, first-delay, second-delay; int first-count, second-count; :/= 0 *+ &M[ &+ 0*! mutex J. &M[!08 " B Q0R 3!"+,0! 2K &+ 7!@. W 4# 8 B first-delay 80 + H!" *+ $L &+ H B J 0M 0+8! "+ & E 7 N@.!" M second-delay 0B 8
9 region x when B do S 3 wait (mutex); while (!B) { first_count ++; if (second_count > 0) signal (second_delay); signal (mutex); wait (first_delay); first_count --; second_count ++; if (first_count > 0) signal (first_delay); signal (second_delay); wait (second_delay); second_count --; S; if (first_count > 0) signal (first_delay); if (second_count > 0) signal (second_delay); signal (mutex); *+ &' & (Monitors) C C C I 5+ b[ 0K 7 %! (Monitor) 3+!., 7!@ %/ monitor monitor-name { shared variable declarations procedure body P 1 {... procedure body P 2 {... procedure body Pn {... { initialization code. + H /+ B 3+!. 0! "+ 7!@. & + :!" 3R 7 Q0"L &+ _ J condition x, y;.!"! signal 8 wait I/R + " _ J & 7, $V" "K 7!@ U x.wait /R. > 0 x.signal /R %! 7!@ W $V" 7!@. MV! x.signal /R.!0 h ` /R : H+ $V" 7!@ C 4 > D( E- C 9
10 "!>6 "!>6 :3+! $U monitor dp { enum {thinking, hungry, eating state[5]; condition self[5]; void pickup(int i) // following slides void putdown(int i) // following slides void test(int i) // following slides void init { for (int i = 0; i < 5; i++) state[i] = thinking;!0s%+ 80 I%] H0!+ 80 I%] void pickup (int i) { void putdown (int i) { state [i] = hungry; state [i] = thinking; test [i]; // test left and right neighbors if (state [i]!= eating) test ((i+4) % 5); self [i].wait; test ((i+1) % 5); void test(int i) { if ( (state[(i + 4) % 5]!= eating) && (state[i] == hungry) && (state[(i + 1) % 5]!= eating)) { state[i] = eating; self[i].signal; C 3 C 3 semaphore mutex = 1; semaphore next = 0; int next-count = 0; wait(mutex); body of F; if (next-count > 0) signal(next) signal(mutex); :(!0M +) J :!" :%> 7 &U[V + F I80.!" :/= 3+! 0! 0*! :! gk 0/. 8. x _ J &+ semaphore x_sem = 0; int x_count = 0; : " 7!@ 7 Q0"L &+ x.signal 8 x.wait I/R x.wait x_count ++; if (next_count > 0) signal (next); signal (mutex); wait (x_sem); x_count --; x.signal if (x_count > 0) { next_count ++; signal (x_sem); wait (next); next_count --; C 3 C 3 0"%( 7 " +7+ 7!@ - + R ).! " 8 (FCFS) 7!@ : /V I8 ::!,"(8 <" 8 2 0B 0K 7! :%! X80.!" "K x.wait (c) Q0"L &+ 2 0B 0K.!" &* wait "K + &, b*l Q0R. c $V" 7!@ < / &+ 7!@,"(8 0/ 3"R &+ c 0M.!" Kj 0,"(8 0/ :]" & 7!@!" > x.signal V8.!" +7+ H+ &! monitor ResourceAllocation { boolean busy; condition x; void acquire (int time) { if (busy) x.wait (time); busy = true; void release { busy = false; x.signal ; void init { busy = false; // A Correct Use: R.acquire (t); access the resource R.release ; 10
11 F13 ( "B,GH I -!3 G> 1+J '( 08E!,)+ :+ 8 3/! 7,0!! 5+ b[ )" & + 0K 7! :!@ ' 0!!!, C2+ Q0"L &+ 7+ k &+ 7>?) 38+, :/ 7!@..!7E %D 0 & gk k, :/ 7!@...., :/ 7!@. )!/R,*L ^ I : ' 0 ( 18 ) l' < :+ ' 0 :!"7E 0 7 _ 8! + ),*L 7 3/2 +? ! 0!!"K "K !@.! <T b*l 0! k "+ 3+!!808 W0! 7 0"R 38+ 7!@ `.! gk!"k &+ 0 3+! 0K 2 KL *+ &' & 2 KL3 + V 7 - e" 2 405" 0!. 7!@ W7!@] 8 %0] mutex 7 " &U[V 0! 0 3!+5+,> 2 405".!!! 7,B* + M8 7 + &U[V 0!!! 7,B* +.!"! )" H "K V 8 _ J. 7 $V" 7!@ 3!? " 0!.!"! turnstile < &+,"(8 + $L 0K 2000 k+ 7,B* + 7!@. ) 0! ! (interrupt mask) &V8 M 7! spinlock V 7 7!@ ] ) 0! &U[V 7,B* + &) ^" V :.!". "! " 8 mutex 3"R &+ dispatcher object 7 3" :D/.!!,/'!K0 7 3" dispatcher object 7! +.!0! _ J &+ 0)+,!K0..!.! n@ 3@ Q5" : &+ 14 H10 H9 H8 H7 H6 H3 H2 :)" & + :/ 0+0! 4"( :3+ R ) C++ :7 & ! <T * N 0! 0 :/ : " :/ n@ 8-0! G' 0 * :/ n@. I0! 0! & ! G' 0 )" & + K < / 7 / 3!!,! 7 = n@ I0 0! 780 & 7 / K / / 3!!,! 7 = n@ I0 0! 780 & 7 N+ K 11
Chapter 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 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 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!
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 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 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 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. 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 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 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 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 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 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
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 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 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 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 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 informationChapter 6: Synchronization
Chapter 6: Synchronization Module 6: Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
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 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. 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 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 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 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 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 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 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 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 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 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 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 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 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. 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 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 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 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 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 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 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 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 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 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 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 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 informationChe-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University
Che-Wei Chang chewei@mail.cgu.edu.tw Department of Computer Science and Information Engineering, Chang Gung University 1. Introduction 2. System Structures 3. Process Concept 4. Multithreaded Programming
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 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 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 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 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 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 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
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 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 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 informationComputer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: Process Synchronization Examples
Computer Science 322 Operating Systems Mount Holyoke College Spring 2008 Topic Notes: Process Synchronization Examples Bounded Buffer Example leaving one buffer slot empty int buffer[n]; int in=0; int
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 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 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 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 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 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 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
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 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 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 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 Opera;ng Systems Midterm Review. Yashwant K Malaiya Spring 2018
CS370 Opera;ng Systems Midterm Review Yashwant K Malaiya Spring 2018 1 1 Computer System Structures Computer System Opera2on Stack for calling func2ons (subrou2nes) I/O Structure: polling, interrupts,
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 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 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 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 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 informationSynchronization Basic Problem:
Synchronization Synchronization Basic Problem: If two concurrent processes are accessing a shared variable, and that variable is read, modified, and written by those processes, then the variable must be
More informationInterprocess Communication 11
Interprocess Communication 11 Only a brain-damaged operating system would support task switching and not make the simple next step of supporting multitasking. Calvin Keegan Processes Abstraction of a running
More informationSynchronization Spinlocks - Semaphores
CS 4410 Operating Systems Synchronization Spinlocks - Semaphores Summer 2013 Cornell University 1 Today How can I synchronize the execution of multiple threads of the same process? Example Race condition
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 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 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 informationSynchronization Classic Problems
CS 4410 Operating Systems Synchronization Classic Problems Summer 2013 Cornell University 1 Today What practical problems can we solve with semaphores? Bounded-Buffer Problem Producer-Consumer Problem
More informationCS3733: Operating Systems
Outline CS3733: Operating Systems Topics: Synchronization, Critical Sections and Semaphores (SGG Chapter 6) Instructor: Dr. Tongping Liu 1 Memory Model of Multithreaded Programs Synchronization for coordinated
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 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
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 informationSemaphores (by Dijkstra)
CSCI 4401 Principles of Operating Systems I Process Synchronization II: Classic Problems Vassil Roussev vassil@cs.uno.edu Semaphores (by Dijkstra) A higher-level way of doing synchronization between threads/processes
More informationCS370 Operating Systems Midterm Review
CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between
More informationModule 5: Process Synchronization. Reading: Chapter 6
Module 5: Process Synchronization Reading: Chapter 6 1 Solutions Classic problems What is the problem? Process Synchronization Synchr. In Real Systems 2 Background Producer/Consumer Critical Section Problem
More informationAnnouncements. Office hours. Reading. W office hour will be not starting next week. Chapter 7 (this whole week) CMSC 412 S02 (lect 7)
Office hours Announcements W office hour will be 10-11 not 11-12 starting next week Reading Chapter 7 (this whole week) 1 Problems with the Producer-Consumer Shared Memory Solution Consider the three address
More informationProcess/Thread Synchronization
CSE325 Principles of Operating Systems Process/Thread Synchronization David Duggan dduggan@sandia.gov February 14, 2013 Reading Assignment 7 Chapter 7 Deadlocks, due 2/21 2/14/13 CSE325: Synchronization
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 informationComp 310 Computer Systems and Organization
Comp 310 Computer Systems and Organization Lecture #10 Process Management (CPU Scheduling & Synchronization) 1 Prof. Joseph Vybihal Announcements Oct 16 Midterm exam (in class) In class review Oct 14 (½
More informationProcess/Thread Synchronization
CSE325 Principles of Operating Systems Process/Thread Synchronization David Duggan dduggan@sandia.gov March 1, 2011 The image cannot be displayed. Your computer may not have enough memory to open the image,
More informationSynchronization Principles I
CSC 256/456: Operating Systems Synchronization Principles I John Criswell University of Rochester 1 Synchronization Principles Background Concurrent access to shared data may result in data inconsistency.
More informationOPERATING SYSTEM CONCEPTS 操作系统概念 东南大学计算机学院. Baili Zhang/ Southeast Process synchronization
OPERATING SYSTEM CONCEPTS 操作系统概念 东南大学计算机学院 Baili Zhang/ Southeast 1 6. Process synchronization Objectives To introduce the critical-section problem, whose solutions can be used to ensure the consistency
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 informationClassic Problems of Synchronization
Classic Problems of Synchronization Bounded-Buffer Problem s-s Problem Dining Philosophers Problem Monitors 2/21/12 CSE325 - Synchronization 1 s-s Problem s s 2/21/12 CSE325 - Synchronization 2 Problem
More information