CSCI 447 Operating Systems Filip Jagodzinski
|
|
- Susanna Wilcox
- 5 years ago
- Views:
Transcription
1 Filip Jagodzinski
2 Announcements Homework 2 you have 2 weeks start now Book questions including two custom ones A single programming task File names and directories, class conventions homework2-script, or homework2-script.txt lab2-script, or lab2-script.txt
3 Announcements Homework 2 you have 2 weeks start now Book questions including two custom ones A single programming task File names and directories, class conventions homework2-script, or homework2-script.txt lab2-script, or lab2-script.txt Git (any repo) conventions Do not push.o or executables to a git repo why? Use.gitignore or add files one-by-one (Example shown right) file :.gitignore *.o *.exe *.pdf
4 Review Asynchronous cancellation Deferred cancellation A thread immediately terminates the target thread The target thread periodically checks in to find out if it should be terminated; if so, does it in an orderly fashion
5 Review Asynchronous cancellation Deferred cancellation A thread immediately terminates the target thread The target thread periodically checks in to find out if it should be terminated; if so, does it in an orderly fashion Q: Why might asynchronous thread cancellation be problematic? buffer thread 1 thread 2
6 Review Thread B i1: count = count + 1 i2: count = count - 1
7 Review Thread B i1: count = count + 1 i2: count = count - 1 a1: load count a2: add 1 a3: store count Register/ALU view b1: load count b2: subtract 1 b3: store count
8 Review Thread B i1: count = count + 1 i2: count = count - 1 a1: load count a2: add 1 a3: store count Register/ALU view b1: load count b2: subtract 1 b3: store count Assume initial value of count = 4 a1 < b1 < a2 < a3 < b2 < b3 count = 3 a1 < a2 < a3 < b1 < b2 < b3 count = 4 a1 < a2 < b1 < b2 < b3 < a3 count = 5 b1 < b2 < a1 < b3 < a2 < a3 count = 5
9 Review Peterson s Solution do { flag[i] = true; turn = j; while (flag[j] && turn == j){}; Critical section flag[i] = false // other stuff (remainder) } while(true); Works for 2 processes/threads j = 1-i; Requires additional (shared) data : int turn; boolean flag[2]; Process i sets flag[i] to true (to specify, hey, I m ready to entry my critical section ) A process sets turn to j (the other process) If both processes try to enter their critical section, although flag might be [1,1], because turn is a single shared value, only one of the processes will succeed in setting turn to the other process.
10 Review Most operating systems allow, via a system call, the use of a mutex this allows the application programmer to solve a critical section problem Mutex : Mutual Exclusion This high level idea is the following : have the OS provide system calls for a lock that can be used to control access to a critical section. do { // acquire lock Critical section acquire(){ while(!available) {}; available = false } // release lock // other stuff (remainder) } while(true); release(){ available = true } available, in this implementation, is the variable that is used to specify whether a process is in its critical section
11 In-class exercise
12 Review A solution to the critical section problem must satisfy 3 criteria Mutual exclusion : if a process is executing its critical section, no other process can be executing its critical section Progress : If no process is executing its critical section, AND some process wants to enter its critical section, then only those processes NOT executing code in their other sections can decide who enters Bounded Waiting : there must be a limit on the number of times that ANOTHER process is allowed to enter its critical section after a process has made a request to enter its critical section
13 Today Chapter 5 s Deadlock
14 Synchronization When more than 1 thread is running, synchronization is important Some terminology, assuming two events : Serialization : Event A must happen before? Event B Mutual Exclusion : Events A and B must NOT happen? at the same time Concurrent :?
15 Synchronization When more than 1 thread is running, synchronization is important Some terminology, assuming two events : Serialization : Event A must happen before Event B Mutual Exclusion : Events A and B must NOT happen? at the same time Concurrent :?
16 Synchronization When more than 1 thread is running, synchronization is important Some terminology, assuming two events : Serialization : Event A must happen before Event B Mutual Exclusion : Events A and B must NOT happen at the same time Concurrent :?
17 Synchronization When more than 1 thread is running, synchronization is important Some terminology, assuming two events : Serialization : Event A must happen before Event B Mutual Exclusion : Events A and B must NOT happen at the same time Concurrent : More than 1 thread making progress... it is not possible to know a priori what instruction history will be realized
18 Instruction Execution Q: How might you enforce a certain order of instruction execution?
19 Instruction Execution Q: How might you enforce a certain order of instruction execution?
20 Instruction Execution A1 A2 A3 Thread M M1 M2 M3 Q: What are the possible orderings, histories, of A1-A3 and M1-M3 if threads A and M are run concurrently? Q: How many unique execution histories are there in this scenario?
21 Instruction Execution A1 A2 A3 Thread M M1 M2 M3 What if only one the below two execution histories were acceptable Desired execution order : A1 < A2 < M1 < M2 < M3 < A3 Desired execution order : A1 < M1 < A2 < M2 < M3 < A3 Q: How would you impose these orders using sleep?
22 Instruction Execution A1 A2 A3 Thread M M1 M2 M3 What if only one the below two execution histories were acceptable Desired execution order : A1 < A2 < M1 < M2 < M3 < A3 Desired execution order : A1 < M1 < A2 < M2 < M3 < A3 Q: Is using sleep() a practical solution?
23 Instruction Execution Q: How is it done in the real world?
24 Instruction Execution Q: How is it done in the real world? A is a data structure that permits threads to coordinate among each other and specify which thread(s) wait and which thread(s) execute. Invented by Edsger Dijkstra (for CS applications) semaphore : a system of sending messages
25 s A data structure that contains only a single non-negative integer as a datum int value
26 s A data structure that contains only a single non-negative integer as a datum The integer can be initialized to any nonnegative value, but once declared and set, it is modified only by several methods (there are no direct setter and getter methods) int value Q: Why are there no setter and getter methods for semaphores?
27 s A data structure that contains only a single non-negative integer as a datum The integer can be initialized to any nonnegative value, but once declared and set, it is modified only by several methods (there are no direct setter and getter methods) Operation 1 : increment Operation 2 : decrement int value + (int) + increment + decrement
28 s A data structure that contains only a single non-negative integer as a datum The integer can be initialized to any nonnegative value, but once declared and set, it is modified only by several methods (there are no direct setter and getter methods) Operation 1 : increment Operation 2 : decrement The method is the constructor; it creates and returns a reference variable to a new int value + (int) + increment + decrement
29 s A data structure that contains only a single non-negative integer as a datum The integer can be initialized to any nonnegative value, but once declared and set, it is modified only by several methods (there are no direct setter and getter methods) Operation 1 : increment Operation 2 : decrement The method is the constructor; it creates and returns a reference variable to a new int value + (int) + increment + decrement Q: Now that we have the structure, what is the behavior of the? Or, how is it used?
30 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore int value + (int) + increment + decrement
31 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore int value + (int) + increment + decrement Thread notifies the scheduler that it cannot proceed. Scheduler will prevent the thread from running until an event occurs that causes the thread to become unblocked
32 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement
33 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement Sometimes referred to as waking
34 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement Q: Which thread is executed after a shared s value is incremented?
35 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement Q: Which thread is executed after a shared s value is incremented? A: Both the thread that is unblocked AND the thread that issued the increment are scheduled concurrently... Q: In which order?
36 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement When a thread signals a, it has no knowledge of how many other threads (if any) are waiting
37 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement The nuances of semaphores results in several unique use scenarios
38 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement The nuances of semaphores results in several unique use scenarios Incrementing may affect other threads Decrementing directly affects only the thread that issued the call
39 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement The nuances of semaphores results in several unique use scenarios Incrementing is often referred to as signal() Decrementing is often referred to as wait()
40 s If decrement would result in the datum being negative, then the thread that issued the decrement will be blocked and will not continue until ANOTHER thread increments the semaphore If increment occurs, an already waiting thread is unblocked. int value + (int) + increment + decrement Increment and decrement refer to what a DOES (to the value) Signal and Wait describe what they are USED FOR Dijkstra, because of this confusion referred to increment as V, and decrement as P use a meaningless name rather than a confusing one
41 s The data structure shown right is the user (software) view. int value + (int) + increment + decrement
42 s The data structure shown right is the user (software) view. When a semaphore is created by the OS, the object has additional information there is needed a list of processes/threads that have invoked the decrement method, and which are blocked typedef struct{ int value; struct process *list; } semaphore int value + (int) + increment + decrement int value - process *list + increment + decrement
43 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement()
44 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement() Task : Draw the variable, object reference diagram that results after this line of code is executed
45 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement() asem value = 3
46 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement() asem value = 4 Q: When asem s value is incremented from 3 to to 4, what effect does that have on?
47 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement() asem value = 4 Q: When asem s value is incremented from 3 to to 4, what effect does that have on? Q: When asem s value is incremented to 4, what effect does that have on other threads?
48 s Syntax is straight-forward but it is OS specific, so the pseudocode description is used in most textbooks asem = (3) asem.increment() asem.decrement() asem value = 3 Q: When asem s value is incremented from 3 to to 4, what effect does that have on? Q: When asem s value is incremented to 4, what effect does that have on other threads? Q: When asem s value is decremented from 4 to 3, what effect does that have on and on other threads?
49 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) Q: What is achieved when the code in the yellow box is executed?
50 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 0
51 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 0 Q: What is achieved when the code in the yellow box is executed?
52 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 1
53 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 1 Q: What is achieved when the code in the yellow box is executed?
54 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 0
55 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 0 Q: What is achieved when the code in the yellow box is executed?
56 s Another example mysem = (0) mysem.increment() mysem.decrement() mysem.decrement() mysem.decrement() print( hello ) mysem value = 0 self stalls is the last decrement executed? Is the print statement executed?
57 s s are used to halt a thread and to enforce running one thread in a specific sequence relative to another
58 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) In-class exercise 1 Thread B a1 b1
59 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Task : Explain via prose how to use a semaphore(s) to attain this goal Thread B a1 b1
60 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) Thread B a1 b1
61 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 Task : Be able to explain why the above use of the ensures the goal
62 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 Q: Does the use of the by the two threads guarantee that will complete prior to Thread B starting?
63 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 We do not know how the OS will schedule the two threads. Q: What are the scheduling choices?
64 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 Choice 1 : < Thread B Choice 2 : Thread B < Task : Be sure you understand both execution orders
65 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 Choice 1 : < Thread B Choice 2 : Thread B < Q: What Is the sequence of events when Thread A is scheduled to execute first? (on the board walk through)
66 s Assume a1 writes to a file, and b1 prints a line from the file (hence reads from the file) Goal : We want a1 to complete before b1 begins Already run code sem = (0) a1 sem.increment() Thread B sem.decrement() b1 Choice 1 : < Thread B Choice 2 : Thread B < Q: What Is the sequence of events when Thread B is scheduled to execute first? (on the board walk through)
67 s In-class exercise 2 a1 a2 Thread B b1 b2 Goals a1 must happen before b2 b1 must happen before a2
68 s Sample solution (in class) Already run code Thread B a1 b1 a2 b2 Goals a1 must happen before b2 b1 must happen before a2
69 s Sample solution (in class) Already run code Thread B a1 b1 a2 b2 Goals a1 must happen before b2 b1 must happen before a2 Q : How many unique solutions are there? Q : What is the fewest number of semaphores needed?
70 Deadlock sem1 = (0) sem2 = (0) a1 sem1.increment() sem2.decrement() a2 Thread B b1 sem2.increment() sem1.decrement() b2 0 0 We saw that the above use of two semaphores enforced that a1 happen before b2, and b1 happen before a2 Q: Is use of semaphores always safe?
71 Deadlock Thread B sem1 = (0) sem2 = (0) a1 a2 b1 b2 0 0 We saw that the above use of two semaphores enforced that a1 happen before b2, and b1 happen before a2 Q: Is use of semaphores always safe? Task : Add method calls to sem1 and sem2 such that and Thread B do not execute to completion.
72 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first?
73 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1
74 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1 sem1 -> -1 (attempt, A self blocks)
75 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1 sem1 -> -1 (attempt, A self blocks) b1
76 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1 sem1 -> -1 (attempt, A self blocks) b1 sem2 -> -1 (attempt, B self blocks)
77 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1 sem1 -> -1 (attempt, A self blocks) b1 sem2 -> -1 (attempt, B self blocks) Q: At this point what happens?
78 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 < Thread B Q: What is the result of the execution of the two Threads, assuming A is scheduled first? a1 sem1 -> -1 (attempt, A self blocks) b1 sem2 -> -1 (attempt, B self blocks) Deadlock
79 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 Thread B < Q: What is the result of the execution of the two Threads, assuming B is scheduled first?
80 Deadlock sem1 = (0) sem2 = (0) a1 sem1.decrement() sem2.increment() a2 Thread B b1 sem2.decrement() sem1.increment() b2 0 0 Thread B < Q: What is the result of the execution of the two Threads, assuming B is scheduled first? Also a Deadlock
81 Mutex Thread B count = count + 1 count = count +1 Add semaphores to the above two threads to enforce mutual exclusion to the shared variable count Hint : This can be implemented with a single semaphore Unlike previously, we don t care which of the two threads is scheduled first Further assume that we do NOT want to decompose the above 2 instructions into fetch, update, and WB steps
82 Mutex mutex = (1) mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() Assume the above decrement and increment invocations are placed among 2 threads, and B, run concurrently. Q: What value should the semaphore mutex be initialized to so that its use solves the critical section problem for Threads A and B? A : -1 B : 0 C : 1 D : 2
83 Mutex mutex = (1) 1 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() Q: What are the possible sequences of scheduling/execution?
84 Mutex mutex = (1) 1 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Q: What are the possible sequences of scheduling/execution? Thread B <
85 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 Q: Does this self-block A?
86 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 Q: Because of duplicated pipelines, threading, etc., and Thread B are being executed concurrently at this point, what happens if B for some reason is scheduled?
87 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 B decrements : mutex -> -1 (attempt, blocks)
88 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 B decrements : mutex -> -1 (attempt, blocks) A updates count
89 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 B decrements : mutex -> -1 (attempt, blocks) A updates count A increments : mutex -> 0 (B unblocked)
90 Mutex mutex = (1) 0 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 B decrements : mutex -> -1 (attempt, blocks) A updates count A increments : mutex -> 0 (B unblocked) B updates count
91 Mutex mutex = (1) 1 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < A decrements : mutex -> 0 B decrements : mutex -> -1 (self blocks) A updates count A increments : mutex -> 0 (B unblocked) B updates count B increments : mutex -> 1
92 Mutex mutex = (1) 1 mutex.decrement() count = count + 1 mutex.increment() Thread B mutex.decrement() count = count +1 mutex.increment() < Thread B Thread B < Task : Be able to step through the same code for the other sequence
93 Mutex Q: What is the utility of using semaphores to impose mutex versus the use of Peterson s solution? Q: Does the use of semaphores satisfy all of the conditions needed for a solution to the critical section problem?
94 Mutex Thread B Thread C count = count + 1 count = count +1 count = count +1 Q: What is the minimum number of semaphores needed to enforce mutual exclusion among these three threads, and what should the semaphore(s) be initialized to? A : A single semaphore, initialized to 0 B : Two semaphores, both initialized to 0 C : Three semaphores, each initialized to 0 D : None of the above
95 Mutex mutex.wait() count = count + 1 mutex.signal() Thread B mutex.wait() count = count +1 mutex.signal() Thread C mutex.wait() count = count +1 mutex.signal() Q: What is the minimum number of semaphores needed to enforce mutual exclusion among these three threads, and what should the semaphore(s) be initialized to? A : A single semaphore, initialized to 0 B : Two semaphores, both initialized to 0 C : Three semaphores, each initialized to 0 D : None of the above A single semaphore, initialized to 1
96 Multiplex Q: What is one functional purpose for initializing a semaphore to a non-zero value when 1, 2, 3, or n threads use that semaphore? a = (8) 8
97 Multiplex Thread B x = x + 1 x = x - 12 Thread C x = 4 Create one or more semaphores and invoke the wait and signal methods among Threads A-C to enforce an upper limit of 2 for the number of threads that can access concurrently the shared variable x
98 Multiplex multiplex = (2) 2 multiplex.dec() x = x + 1 multiplex.inc() Thread B multiplex.dec() x = x 12 multiplex.inc() Thread C multiplex.dec() x = 4 multiplex.inc() Q: How many possible choices are there of scheduling the 3 Threads?
99 Multiplex multiplex = (2) 2 multiplex.dec() x = x + 1 multiplex.inc() Thread B multiplex.dec() x = x 12 multiplex.inc() Thread C multiplex.dec() x = 4 multiplex.inc() Q: How many possible choices are there of scheduling the 3 Threads? < Thread B < Thread C < Thread C < Thread B Thread B < < Thread C Thread B < Thread C < Thread C < < Thread B Thread C < Thread B <
100 Multiplex multiplex = (2) 2 multiplex.dec() x = x + 1 multiplex.inc() Thread B multiplex.dec() x = x 12 multiplex.inc() Thread C multiplex.dec() x = 4 multiplex.inc() Q: How many possible choices are there of scheduling the 3 Threads? < Thread B < Thread C < Thread C < Thread B Thread B < < Thread C Thread B < Thread C < Thread C < < Thread B Thread C < Thread B < Regardless of the scheduling, only 2 Threads at any one time may access the code that updates the value of x.
101 Up Next Implementation of Mutex using blitz Chapter 5 : Monitors Chapter 6 : Scheduling
CSCI 447 Operating Systems Filip Jagodzinski
Filip Jagodzinski Announcements Reading Task Should take 30 minutes-ish maximum Homework 2 Book questions including two custom ones will be posted to the course website today Programming tasks will be
More informationDeadlock and Monitors. CS439: Principles of Computer Systems February 7, 2018
Deadlock and Monitors CS439: Principles of Computer Systems February 7, 2018 Last Time Terminology Safety and liveness Atomic Instructions, Synchronization, Mutual Exclusion, Critical Sections Synchronization
More informationLecture 8: September 30
CMPSCI 377 Operating Systems Fall 2013 Lecture 8: September 30 Lecturer: Prashant Shenoy Scribe: Armand Halbert 8.1 Semaphores A semaphore is a more generalized form of a lock that can be used to regulate
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 informationIntroduction to OS Synchronization MOS 2.3
Introduction to OS Synchronization MOS 2.3 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Challenge How can we help processes synchronize with each other? E.g., how
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 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 informationDeadlock and Monitors. CS439: Principles of Computer Systems September 24, 2018
Deadlock and Monitors CS439: Principles of Computer Systems September 24, 2018 Bringing It All Together Processes Abstraction for protection Define address space Threads Share (and communicate) through
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 information2.c Concurrency Mutual exclusion & synchronization mutexes. Unbounded buffer, 1 producer, N consumers
Mutual exclusion & synchronization mutexes Unbounded buffer, 1 producer, N consumers out shared by all consumers mutex among consumers producer not concerned: can still add items to buffer at any time
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 informationCS4411 Intro. to Operating Systems Exam 1 Fall points 10 pages
CS4411 Intro. to Operating Systems Exam 1 Fall 2005 (October 6, 2005) 1 CS4411 Intro. to Operating Systems Exam 1 Fall 2005 150 points 10 pages Name: Most of the following questions only require very short
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 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 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 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 informationSynchronization. Before We Begin. Synchronization. Credit/Debit Problem: Race Condition. CSE 120: Principles of Operating Systems.
CSE 120: Principles of Operating Systems Lecture 4 Synchronization January 23, 2006 Prof. Joe Pasquale Department of Computer Science and Engineering University of California, San Diego Before We Begin
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 informationOperating Systems ECE344
Operating Systems ECE344 Ding Yuan Announcement & Reminder Lab 0 mark posted on Piazza Great job! One problem: compilation error I fixed some for you this time, but won t do it next time Make sure you
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 informationEECS 482 Introduction to Operating Systems
EECS 482 Introduction to Operating Systems Winter 2018 Harsha V. Madhyastha Recap Multi-threaded code with monitors: Locks for mutual exclusion Condition variables for ordering constraints Every thread
More informationChapters 5 and 6 Concurrency
Operating Systems: Internals and Design Principles, 6/E William Stallings Chapters 5 and 6 Concurrency Patricia Roy Manatee Community College, Venice, FL 2008, Prentice Hall Concurrency When several processes/threads
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 informationG52CON: Concepts of Concurrency
G52CON: Concepts of Concurrency Lecture 11: Semaphores I" Brian Logan School of Computer Science bsl@cs.nott.ac.uk Outline of this lecture" problems with Peterson s algorithm semaphores implementing semaphores
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 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 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 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 informationSWEN-220 Mathematical Models of Software. Process Synchronization Critical Section & Semaphores
SWEN-220 Mathematical Models of Software Process Synchronization Critical Section & Semaphores 1 Topics The critical section Synchronization using busy-wait Semaphores 2 The Critical Section Processes
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 informationSemaphores. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University
Semaphores Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3052: Introduction to Operating Systems, Fall 2017, Jinkyu Jeong (jinkyu@skku.edu) Synchronization
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 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 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 informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
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 informationSynchronization. Before We Begin. Synchronization. Example of a Race Condition. CSE 120: Principles of Operating Systems. Lecture 4.
CSE 120: Principles of Operating Systems Lecture 4 Synchronization October 7, 2003 Before We Begin Read Chapter 7 (Process Synchronization) Programming Assignment #1 Due Sunday, October 19, midnight Prof.
More informationLast Class: Synchronization. Review. Semaphores. Today: Semaphores. MLFQ CPU scheduler. What is test & set?
Last Class: Synchronization Review Synchronization Mutual exclusion Critical sections Example: Too Much Milk Locks Synchronization primitives are required to ensure that only one thread executes in a critical
More informationOpera&ng Systems ECE344
Opera&ng Systems ECE344 Lecture 6: Synchroniza&on (II) Semaphores and Monitors Ding Yuan Higher- Level Synchroniza&on We looked at using locks to provide mutual exclusion Locks work, but they have some
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 informationWhat is the Race Condition? And what is its solution? What is a critical section? And what is the critical section problem?
What is the Race Condition? And what is its solution? Race Condition: Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular
More informationLecture. DM510 - Operating Systems, Weekly Notes, Week 11/12, 2018
Lecture In the lecture on March 13 we will mainly discuss Chapter 6 (Process Scheduling). Examples will be be shown for the simulation of the Dining Philosopher problem, a solution with monitors will also
More informationThe University of Texas at Arlington
The University of Texas at Arlington Lecture 10: Threading and Parallel Programming Constraints CSE 5343/4342 Embedded d Systems II Objectives: Lab 3: Windows Threads (win32 threading API) Convert serial
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 informationKING FAHD UNIVERSITY OF PETROLEUM & MINERALS. Information and Computer Science Department. ICS 431 Operating Systems. Lab # 9.
KING FAHD UNIVERSITY OF PETROLEUM & MINERALS Information and Computer Science Department ICS 431 Operating Systems Lab # 9 Semaphores Objectives: In this lab, we will use semaphore to solve various synchronization
More informationCSE 120: Principles of Operating Systems. Lecture 4. Synchronization. October 7, Prof. Joe Pasquale
CSE 120: Principles of Operating Systems Lecture 4 Synchronization October 7, 2003 Prof. Joe Pasquale Department of Computer Science and Engineering University of California, San Diego 2003 by Joseph Pasquale
More informationCS 153 Design of Operating Systems Winter 2016
CS 153 Design of Operating Systems Winter 2016 Lecture 7: Synchronization Administrivia Homework 1 Due today by the end of day Hopefully you have started on project 1 by now? Kernel-level threads (preemptable
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 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 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 informationThreading and Synchronization. Fahd Albinali
Threading and Synchronization Fahd Albinali Parallelism Parallelism and Pseudoparallelism Why parallelize? Finding parallelism Advantages: better load balancing, better scalability Disadvantages: process/thread
More informationIT 540 Operating Systems ECE519 Advanced Operating Systems
IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (5 th Week) (Advanced) Operating Systems 5. Concurrency: Mutual Exclusion and Synchronization 5. Outline Principles
More informationPROCESS SYNCHRONIZATION
PROCESS SYNCHRONIZATION Process Synchronization Background The Critical-Section Problem Peterson s Solution Synchronization Hardware Semaphores Classic Problems of Synchronization Monitors Synchronization
More informationCOMP 3430 Robert Guderian
Operating Systems COMP 3430 Robert Guderian file:///users/robg/dropbox/teaching/3430-2018/slides/06_concurrency/index.html?print-pdf#/ 1/76 1 Concurrency file:///users/robg/dropbox/teaching/3430-2018/slides/06_concurrency/index.html?print-pdf#/
More informationThe University of Texas at Arlington
The University of Texas at Arlington Lecture 6: Threading and Parallel Programming Constraints CSE 5343/4342 Embedded Systems II Based heavily on slides by Dr. Roger Walker More Task Decomposition: Dependence
More informationUNIX Input/Output Buffering
UNIX Input/Output Buffering When a C/C++ program begins execution, the operating system environment is responsible for opening three files and providing file pointers to them: stdout standard output stderr
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 informationCMSC421: Principles of Operating Systems
CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating
More informationLast Class: Deadlocks. Today
Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock
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 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 informationConcurrency: a crash course
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Concurrency: a crash course Concurrent computing Applications designed as a collection of computational units that may execute
More informationConcurrency. On multiprocessors, several threads can execute simultaneously, one on each processor.
Synchronization 1 Concurrency On multiprocessors, several threads can execute simultaneously, one on each processor. On uniprocessors, only one thread executes at a time. However, because of preemption
More informationRecap: Thread. What is it? What does it need (thread private)? What for? How to implement? Independent flow of control. Stack
What is it? Recap: Thread Independent flow of control What does it need (thread private)? Stack What for? Lightweight programming construct for concurrent activities How to implement? Kernel thread vs.
More informationCSE 120. Fall Lecture 6: Semaphores. Keith Marzullo
CSE 120 Principles of Operating Systems Fall 2007 Lecture 6: Semaphores Keith Marzullo Announcements Homework #2 out Homework #1 almost graded... Discussion session on Wednesday will entertain questions
More informationHomework Assignment #5
Homework Assignment #5 Question 1: Scheduling a) Which of the following scheduling algorithms could result in starvation? For those algorithms that could result in starvation, describe a situation in which
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 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 informationCS 333 Introduction to Operating Systems. Class 4 Concurrent Programming and Synchronization Primitives
CS 333 Introduction to Operating Systems Class 4 Concurrent Programming and Synchronization Primitives Jonathan Walpole Computer Science Portland State University 1 Concurrent programming Assumptions:
More informationCS3502 OPERATING SYSTEMS
CS3502 OPERATING SYSTEMS Spring 2018 Synchronization Chapter 6 Synchronization The coordination of the activities of the processes Processes interfere with each other Processes compete for resources Processes
More informationMidterm on next week Tuesday May 4. CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9
CS 361 Concurrent programming Drexel University Fall 2004 Lecture 9 Bruce Char and Vera Zaychik. All rights reserved by the author. Permission is given to students enrolled in CS361 Fall 2004 to reproduce
More informationCS 31: Intro to Systems Misc. Threading. Kevin Webb Swarthmore College December 6, 2018
CS 31: Intro to Systems Misc. Threading Kevin Webb Swarthmore College December 6, 2018 Classic thread patterns Agenda Pthreads primitives and examples of other forms of synchronization: Condition variables
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 informationConcurrency and Synchronisation
Concurrency and Synchronisation 1 Learning Outcomes Understand concurrency is an issue in operating systems and multithreaded applications Know the concept of a critical region. Understand how mutual exclusion
More informationProcess Synchronization (Part I)
Process Synchronization (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) Process Synchronization 1393/7/14 1 / 44 Motivation
More informationDealing with Issues for Interprocess Communication
Dealing with Issues for Interprocess Communication Ref Section 2.3 Tanenbaum 7.1 Overview Processes frequently need to communicate with other processes. In a shell pipe the o/p of one process is passed
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 informationThreads and Synchronization. Kevin Webb Swarthmore College February 15, 2018
Threads and Synchronization Kevin Webb Swarthmore College February 15, 2018 Today s Goals Extend processes to allow for multiple execution contexts (threads) Benefits and challenges of concurrency Race
More informationPuzzle: Write synchronization code for oxygen and hydrogen molecules that enforces these constraints.
Problem 2: H 2 O Building Problem There are two kinds of threads, oxygen and hydrogen. In order to assemble these threads into water molecules, we have to create a barrier that makes each thread wait until
More informationCS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 8: Semaphores, Monitors, & Condition Variables
CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring 2004 Lecture 8: Semaphores, Monitors, & Condition Variables 8.0 Main Points: Definition of semaphores Example of use
More informationProgramming Languages
Programming Languages Tevfik Koşar Lecture - XXVI April 27 th, 2006 1 Roadmap Shared Memory Synchronization Spin Locks Barriers Semaphores Monitors 2 1 Memory Architectures Distributed Memory Shared Memory
More informationCS 31: Introduction to Computer Systems : Threads & Synchronization April 16-18, 2019
CS 31: Introduction to Computer Systems 22-23: Threads & Synchronization April 16-18, 2019 Making Programs Run Faster We all like how fast computers are In the old days (1980 s - 2005): Algorithm too slow?
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 informationProgramming Languages
TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Programming Languages Concurrency: Atomic Executions, Locks and Monitors Dr. Michael Petter Winter term 2016 Atomic Executions, Locks and Monitors
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 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 informationOperating Systems CMPSCI 377 Spring Mark Corner University of Massachusetts Amherst
Operating Systems CMPSCI 377 Spring 2017 Mark Corner University of Massachusetts Amherst Clicker Question #1 If we have 100 threads and 100 processors, how often does Hello get printed? (A) 100 times per
More informationMore Types of Synchronization 11/29/16
More Types of Synchronization 11/29/16 Today s Agenda Classic thread patterns Other parallel programming patterns More synchronization primitives: RW locks Condition variables Semaphores Message passing
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 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 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 informationSynchronization. CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han
Synchronization CSCI 3753 Operating Systems Spring 2005 Prof. Rick Han Announcements HW #3 is coming, due Friday Feb. 25, a week+ from now PA #2 is coming, assigned about next Tuesday Midterm is tentatively
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 informationMULTITHREADING AND SYNCHRONIZATION. CS124 Operating Systems Fall , Lecture 10
MULTITHREADING AND SYNCHRONIZATION CS124 Operating Systems Fall 2017-2018, Lecture 10 2 Critical Sections Race conditions can be avoided by preventing multiple control paths from accessing shared state
More informationChapter 5 Concurrency: Mutual Exclusion and Synchronization
Operating Systems: Internals and Design Principles Chapter 5 Concurrency: Mutual Exclusion and Synchronization Seventh Edition By William Stallings Designing correct routines for controlling concurrent
More informationCSE Traditional Operating Systems deal with typical system software designed to be:
CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special
More informationConcurrency and Synchronisation
Concurrency and Synchronisation 1 Sections 2.3 & 2.4 Textbook 2 Making Single-Threaded Code Multithreaded Conflicts between threads over the use of a global variable 3 Inter- Thread and Process Communication
More informationCS11 Java. Fall Lecture 7
CS11 Java Fall 2006-2007 Lecture 7 Today s Topics All about Java Threads Some Lab 7 tips Java Threading Recap A program can use multiple threads to do several things at once A thread can have local (non-shared)
More informationClassical concurrency control: topic overview 1 In these lectures we consider shared writeable data in main memory
Classical concurrency control: topic overview 1 In these lectures we consider shared writeable data in main memory Controlling access by concurrent processes to shared writeable data has been studied as
More informationCS Operating Systems
CS 4500 - Operating Systems Module 4: The Producer-Consumer Problem and Solution Methods Stanley Wileman Department of Computer Science University of Nebraska at Omaha Omaha, NE 68182-0500, USA June 3,
More information