Dan C Marinescu Office HEC 439 B Office hours TuTh 330430 PM Last time Presentation of the paper Programming with Threads by Andrew Birell Thread coordination with a bounded buffer ID: 620592
Download Presentation The PPT/PDF document "COP 4600 Operating Systems Fall 2010" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
COP 4600 Operating Systems Fall 2010
Dan C. Marinescu
Office: HEC 439 B
Office hours:
Tu-Th
3:30-4:30 PMSlide2
Last time:
Presentation of the paper “Programming with Threads” by Andrew
BirellThread coordination with a bounded buffer. WAITNOTIFYToday:Thread coordination with a bounded buffer. AWAITADVANCESEQUENCETICKETSemaphoresDeadlock and Wait for GraphsEnforced modularity on the Intel x86 architectureVirtual MachinesNext TimeScheduling Algorithms
Lecture 22 – Thursday November 4, 2010
Lecture 22
2Slide3
Coordination with bounded buffer
WAIT and NOTIFY can be used to coordinate the SEND and RECIVE systems calls.
This solution creates problems when a NOTIFY is sent before the WAIT. The thread in the WAITING state will never wake up. Lecture 223Slide4
Lecture 22
4Slide5
Lecture 22
5Slide6
AWAIT - ADVANCE solution
A new state, WAITING and two
before-or-after actions that take a RUNNING thread into the WAITING state and back to RUNNABLE state.eventcount variables with an integer value shared between threads and the thread manager; they are like events but have a value. A thread in the WAITING state waits for a particular value of the eventcount AWAIT(eventcount,value)If eventcount >value the control is returned to the thread calling AWAIT and this thread will continue executionIf eventcount ≤value the state of the thread calling AWAIT is changed to WAITING and the thread is suspended.ADVANCE(eventcount) increments the
eventcount by one then
searches the thread_table
for threads waiting for this
eventcount
if it finds a thread and the
eventcount
exceeds the value the thread is waiting for then the state of the thread is changed to RUNNABLE
Lecture 22
6Slide7
Implementation of AWAIT and ADVANCE
Lecture 22
7Slide8
Lecture 22
8Slide9
Solution for a single sender and multiple receivers
Lecture 22
9Slide10
Supporting multiple senders: the sequencer
Sequencer
shared variable supporting thread sequence coordination -it allows threads to be ordered and is manipulated using two before-or-after actions.TICKET(sequencer) returns a negative value which increases by one at each call. Two concurrent threads calling TICKET on the same sequencer will receive different values based upon the timing of the call, the one calling first will receive a smaller value.READ(sequencer) returns the current value of the sequencer Lecture 2210Slide11
Multiple sender solution; only the SEND must be modified
Lecture 22
11Slide12
Semaphores
Introduced by
Dijkstra in 1965Does not require busy waiting Semaphore S – integer variableTwo standard operations modify S: wait() and signal()Originally called P() and V()Less complicatedCan only be accessed via two indivisible (atomic) operationswait (S) { while S <= 0 ; // no-op
S--; }
signal (S) {
S++;
}
12
Lecture 22Slide13
Lecture 22
13Slide14
Lecture 22
14Slide15
Lecture 22
15
Simultaneous conditions for deadlockMutual exclusion: only one process at a time can use a resource.Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes.No preemption: a resource can be released only voluntarily by the process holding it (presumably after that process has finished).Circular wait: there exists a set {P0, P1, …, P0} of waiting processes such that P0 is waiting for a resource that is held by P1, P1
is waiting for a resource that is held by P2, …, Pn
–1 is waiting for a resource that is held by P
n
, and
P
0
is waiting for a resource that is held by
P
0
.Slide16
Wait for graphs
Lecture 22
16Slide17
Evolution of modularity for the Intel architecture x86
Real and Virtual Address Space
The address space size determined by the number of address bits: 24 for 80286 a 16 bit processor modularity enforced through segmentation 32 for 80386 a 32 bit processor each segment could have up to 232 byteswithin each segment support for virtual memoryBackward compatibility17Lecture 22Slide18
Lecture 22
18Slide19
19
Lecture 22Slide20
The increase in the number of lines of operating systems source code
(millions)20Lecture 22Slide21
Virtual machines
First commercial product
IBM VM 370 originally developed as CP-67Advantages:One could run multiple guest operating systems on the same machineAn error in one guest operating system does not bring the machine downAn ideal environment for developing operating systems21Lecture 22