Operating Systems: Process Scheduling
-
Upload
damian-gordon -
Category
Education
-
view
46 -
download
1
Transcript of Operating Systems: Process Scheduling
![Page 1: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/1.jpg)
Processor SchedulingDamian Gordon
![Page 2: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/2.jpg)
Process Scheduling Policies
![Page 3: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/3.jpg)
What are good policies to schedule processes?
Process Scheduling Policies
![Page 4: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/4.jpg)
What are good policies to schedule processes?
1. Maximum Throughput2. Minimize Response Time3. Minimize Turnaround Time4. Minimize Waiting Time5. Maximise CPU Efficiency6. Ensure Fairness For All Jobs
Process Scheduling Policies
![Page 5: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/5.jpg)
MAXIMUM THROUGHPUT
Get as many jobs done as quickly as possible.
There are several ways to achieve this, e.g. run only short jobs, run jobs without interruptions.
Process Scheduling Policies
![Page 6: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/6.jpg)
MINIMIZE RESPONSE TIME
Ensure that interactive requests are dealt with as quickly as possible.
This could be achieved by scheduling just with a lot of I/O jobs first, and leave the computational jobs for later.
Process Scheduling Policies
![Page 7: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/7.jpg)
MINIMIZE TURNAROUND TIME
Ensure that jobs are completed as quickly as possible.
This could be achieved by scheduling just with a lot of computation jobs first, and leave the I/O jobs for later, so there is no user delays.
Process Scheduling Policies
![Page 8: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/8.jpg)
MINIMIZE WAITING TIME
Move jobs out of the READY status as soon as possible.
This could be achieved by reduce the number of users allowed on the system, so that the CPU would be available whenever a job enters the READY status.
Process Scheduling Policies
![Page 9: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/9.jpg)
MAXIMISE CPU EFFICIENCY
Keep the CPU busy 100% of the time.
This could be achieved by scheduling just with a lot of computation jobs, and never run the I/O jobs.
Process Scheduling Policies
![Page 10: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/10.jpg)
ENSURE FAIRNESS FOR ALL JOBS
Give everyone an equal amount of CPU time and I/O time.
This could be achieved by giving all jobs equal priority, regardless of it’s characteristics.
Process Scheduling Policies
![Page 11: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/11.jpg)
Process Scheduling Algorithms
![Page 12: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/12.jpg)
Here are six commonly used process scheduling algorithms
Process Scheduling Algorithms
![Page 13: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/13.jpg)
Here are six commonly used process scheduling algorithms
1. First Come, First Served (FCFS)2. Shortest Job Next (SJN)3. Priority Scheduling4. Shortest Remaining Time (SRT)5. Round Robin6. Multi-Level Queues
Process Scheduling Algorithms
![Page 14: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/14.jpg)
First Come, First Served (FCFS) A very simple algorithm that uses a FIFO
structure. Implemented as a non-pre-emptive
scheduling algorithm. Works well for Batch Processes, where
users don’t expect any interaction.
Process Scheduling Algorithms
![Page 15: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/15.jpg)
Shortest Job Next (SJN) Also called Shortest Job First (SJF). A very simple algorithm that schedules
processes based on CPU cycle time. Implemented as a non-pre-emptive
scheduling algorithm. Works well for Batch Processes, where it
is easy to estimate CPU time.
Process Scheduling Algorithms
![Page 16: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/16.jpg)
Priority Scheduling An algorithm that schedules processes
based on priority. Implemented as a non-pre-emptive
scheduling algorithm. One of the most common algorithms used in
systems that are mainly Batch Processes. If two jobs come in of equal priority are
READY, if works on a FIRST COME, FIRST SERVED basis.
Process Scheduling Algorithms
![Page 17: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/17.jpg)
Shortest Remaining Time (SRT) A pre-emptive scheduling version of the
Shortest Job Next (SJN) algorithm. An algorithm that schedules processes
based on the one which is nearest to completion.
It can only be implemented on systems that are only Batch Processes, since you have to know the CPU time required to complete each job.
Process Scheduling Algorithms
![Page 18: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/18.jpg)
Round Robin A pre-emptive scheduling algorithm that is
used extensively in interactive systems All active processes are given a pre-
determined slice of time (“time quantum”). Choosing the time quantum is the key
decision, for interactive systems the quantum must be small, whereas for batch systems it can be longer.
Process Scheduling Algorithms
![Page 19: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/19.jpg)
Multi-Level Queues This isn’t really a separate scheduling
algorithm, it can be used with others. Jobs are grouped together based on
common characteristics. For example, CPU-bound jobs based in one
queue, and the I/O-bound jobs in another queue, and the process scheduler can select jobs from each queue based on balancing the load.
Process Scheduling Algorithms
![Page 20: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/20.jpg)
Deadlock
![Page 21: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/21.jpg)
Deadlock can be said to occur when a process is allocated some non-sharable resources (such as files, printers or scanners), but is forced to wait for other non-sharable resources.
Deadlock
![Page 22: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/22.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
![Page 23: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/23.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
![Page 24: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/24.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
![Page 25: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/25.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
Is it free?
![Page 26: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/26.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
Is it free?YES
![Page 27: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/27.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
Is it free?Continue
![Page 28: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/28.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
![Page 29: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/29.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
Is it free?
![Page 30: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/30.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
Is it free?NO
![Page 31: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/31.jpg)
Deadlock
Is it free?WAIT
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
![Page 32: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/32.jpg)
Deadlock
Is it free?WAIT
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
![Page 33: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/33.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
Deadlock
![Page 34: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/34.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 35: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/35.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 36: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/36.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 37: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/37.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 38: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/38.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 39: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/39.jpg)
PROGRAM ProcA: BEGIN Do Stuff; Open (File1); Do more stuff; Open (File2); Do stuff;END.
PROGRAM ProcB: BEGIN Do Stuff; Open (File2); Do more stuff; Open (File1); Do stuff;END.
Deadlock
![Page 40: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/40.jpg)
Deadlock
Process A
![Page 41: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/41.jpg)
Deadlock
File 1
File 2
Process A
![Page 42: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/42.jpg)
Deadlock
File 1
File 2
Process A
![Page 43: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/43.jpg)
Deadlock
File 1
File 2
Process A
![Page 44: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/44.jpg)
Deadlock
File 1
File 2
Process A
![Page 45: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/45.jpg)
Deadlock
File 1
File 2
Process A
![Page 46: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/46.jpg)
Deadlock
Process B
![Page 47: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/47.jpg)
Deadlock
Process B
File 1
File 2
![Page 48: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/48.jpg)
Deadlock
Process B
File 1
File 2
![Page 49: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/49.jpg)
Deadlock
Process B
File 1
File 2
![Page 50: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/50.jpg)
Deadlock
Process B
File 1
File 2
![Page 51: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/51.jpg)
Deadlock
Process B
File 1
File 2
![Page 52: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/52.jpg)
Deadlock
Process B
File 1
File 2
Process A
![Page 53: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/53.jpg)
1. Deadlock on file requests2. Deadlock in databases3. Deadlock in dedicated device allocation4. Deadlock in multiple device allocation5. Deadlock in spooling6. Deadlock in a network7. Deadlock in disk sharing
Seven Types of Deadlock
![Page 54: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/54.jpg)
We just saw it:
Deadlock on File Requests
![Page 55: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/55.jpg)
We just saw it:
Deadlock on File Requests
Process B
File 1
File 2
Process A
![Page 56: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/56.jpg)
Only occurs because a process is allowed to lock a resource for the duration of its execution.
Deadlock on File Requests
![Page 57: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/57.jpg)
Similar
Deadlock in Databases
TransactionB
Record 1
Record 2
TransactionA
![Page 58: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/58.jpg)
Deadlock in Databases
Begin transaction TA:
read balance1 [ 100 ]
balance1 = balance1 - 100
if balance < 0
print “insufficient funds”
abort T1
end
write balance1 [ 0 ]
read balance2 [ 100 ]
![Page 59: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/59.jpg)
Deadlock in Databases
Begin transaction TA:
read balance1 [ 100 ]
balance1 = balance1 - 100
if balance < 0
print “insufficient funds”
abort T1
end
write balance1 [ 0 ]
read balance2 [ 100 ]
Begin transaction TB:
read balance2 [ 100 ]
balance2 = balance2 - 100
if balance < 0
print “insufficient funds”
abort T2
end
write balance2 [ 0 ]
read balance1 [ 100 ]
![Page 60: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/60.jpg)
Begin transaction TB:
read balance2 [ 100 ]
balance2 = balance2 - 100
if balance < 0
print “insufficient funds”
abort T2
end
write balance2 [ 0 ]
read balance1 [ 100 ]
Begin transaction TA:
read balance1 [ 100 ]
balance1 = balance1 - 100
if balance < 0
print “insufficient funds”
abort T1
end
write balance1 [ 0 ]
read balance2 [ 100 ]
Deadlock in Databases
![Page 61: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/61.jpg)
Begin transaction TB:
read balance2 [ 100 ]
balance2 = balance2 - 100
if balance < 0
print “insufficient funds”
abort T2
end
write balance2 [ 0 ]
read balance1 [ 100 ]
Deadlock in Databases
Begin transaction TA:
read balance1 [ 100 ]
balance1 = balance1 - 100
if balance < 0
print “insufficient funds”
abort T1
end
write balance1 [ 0 ]
read balance2 [ 100 ]
![Page 62: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/62.jpg)
For example DVD Read/Write drives
Deadlock in Dedicated Device Allocation
![Page 63: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/63.jpg)
Deadlock in Dedicated Device Allocation
ProcessB
ProcessA
DVD-R
1
DVD-R
2
![Page 64: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/64.jpg)
More than over device, e.g. DVD-R, printer, scanner.
Deadlock in Multiple Device Allocation
![Page 65: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/65.jpg)
Deadlock in Multiple Device Allocation
ProcessB
ProcessA
DVD-R
1
Scanner 1
![Page 66: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/66.jpg)
Deadlock in Multiple Device Allocation
ProcessB
ProcessA
DVD-R
1
Scanner 1
ProcessC
Printer1
![Page 67: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/67.jpg)
What is Spooling?
Deadlock in Spooling
![Page 68: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/68.jpg)
What is Spooling?
SPOOL is an acronym for Simultaneous Peripheral Operations On-Line.
Deadlock in Spooling
![Page 69: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/69.jpg)
What is Spooling?
SPOOL is an acronym for Simultaneous Peripheral Operations On-Line.
Deadlock in Spooling
![Page 70: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/70.jpg)
What is Spooling?
SPOOL is an acronym for Simultaneous Peripheral Operations On-Line.
A simple example of a spooling application is print spooling, which places a print job a queue for extended or later processing.
Deadlock in Spooling
![Page 71: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/71.jpg)
What is Spooling?
Deadlock in Spooling
Spool 1
Spool 2
![Page 72: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/72.jpg)
If all 108 of you guys had a 10-page assignment you had to hand up by 11am and you all printed your files at the same time at 10:55am, the spool might first accept page 1 from everyone, then page 2, and so on.,, but if it gets to page 9 and then the spooler is full, things get stuck. The printer might not want to print any jobs unless it has a full 10 pages from any one job, so we are deadlocked.
Deadlock in Spooling
![Page 73: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/73.jpg)
Deadlock in a Network
![Page 74: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/74.jpg)
For example, a medium-sized word-processing centre has seven computers on a network, each on different nodes. C1 receives messages from nodes C2, C6, and C7 and sends messages to only one: C2. C2 receives messages from nodes C1, C3, and C4 and sends messages to only C1 and C3. The direction of the arrows in the diagram indicates the flow of messages.
Deadlock in a Network
![Page 75: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/75.jpg)
Messages received by C1 from C6 and C7 and destined for C2 are buffered in an output queue. Messages received by C2 from C3 and C4 and destined for C1 are buffered in an output queue. As the traffic increases, the length of each output queue increases until all of the available buffer space is filled. At this point C1 can’t accept any more messages (from C2 or any other computer) because there’s no more buffer space available to store them.
Deadlock in a Network
![Page 76: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/76.jpg)
For the same reason, C2 can’t accept any messages from C1 or any other computer, not even a request to send. The communication path between C1 and C2 becomes deadlocked; and because C1 can’t send messages to any other computer except C2 and can only receive messages from C6 and C7, those routes also become deadlocked. C1 can’t send word to C2 about the problem and so the deadlock can’t be resolved without outside intervention.
Deadlock in a Network
![Page 77: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/77.jpg)
Deadlock in Disk Sharing
![Page 78: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/78.jpg)
For example, at an insurance company the system performs many daily transactions. One day the following series of events ties up the system:
Deadlock in Disk Sharing
![Page 79: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/79.jpg)
1. Customer Service (P1) wishes to show a payment so it issues a command to read the balance, which is stored on track 20 of a disk.
Deadlock in Disk Sharing
![Page 80: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/80.jpg)
2. While the control unit is moving the arm to track 20, P1 is put on hold and the I/O channel is free to process the next I/O request.
Deadlock in Disk Sharing
![Page 81: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/81.jpg)
3. While the arm is moving into position, Accounts Payable (P2) gains control of the I/O channel and issues a command to write someone else’s payment to a record stored on track 310. If the command is not “locked out,” P2 will be put on hold while the control unit moves the arm to track 310.
Deadlock in Disk Sharing
![Page 82: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/82.jpg)
4. Because P2 is “on hold” while the arm is moving, the channel can be captured again by P1, which reconfirms its command to “read from track 20.”
Deadlock in Disk Sharing
![Page 83: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/83.jpg)
5. Because the last command from P2 had forced the arm mechanism to track 310, the disk control unit begins to reposition the arm to track 20 to satisfy P1. The I/O channel would be released because P1 is once again put on hold, so it could be captured by P2, which issues a WRITE command only to discover that the arm mechanism needs to be repositioned.
Deadlock in Disk Sharing
![Page 84: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/84.jpg)
This is LIVELOCK.
Deadlock in Disk Sharing
![Page 85: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/85.jpg)
Modelling Deadlock
![Page 86: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/86.jpg)
Process B
File 1
Process A
File 2 File 3
Process c
![Page 87: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/87.jpg)
Process B
File 1
Process A
File 2 File 3
Process c
![Page 88: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/88.jpg)
Process B
File 1
Process A
File 2 File 3
Process c
![Page 89: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/89.jpg)
Process B
File 1
Process A
File 2 File 3
Process c
![Page 90: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/90.jpg)
Starvation:The Dining Philosopher’s
Problem
![Page 91: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/91.jpg)
Born May 11, 1930 Died August 6, 2002 Born in Rotterdam,
Netherlands A Dutch computer
scientist, who received the 1972 Turing Award for fundamental contributions to developing programming languages.
Edsger W. Dijkstra
![Page 92: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/92.jpg)
![Page 93: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/93.jpg)
![Page 94: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/94.jpg)
![Page 95: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/95.jpg)
![Page 96: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/96.jpg)
![Page 97: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/97.jpg)
![Page 98: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/98.jpg)
![Page 99: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/99.jpg)
Semaphores
![Page 100: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/100.jpg)
![Page 101: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/101.jpg)
![Page 102: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/102.jpg)
![Page 103: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/103.jpg)
![Page 104: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/104.jpg)
![Page 105: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/105.jpg)
![Page 106: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/106.jpg)
![Page 107: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/107.jpg)
![Page 108: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/108.jpg)
![Page 109: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/109.jpg)
![Page 110: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/110.jpg)
![Page 111: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/111.jpg)
![Page 112: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/112.jpg)
![Page 113: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/113.jpg)
![Page 114: Operating Systems: Process Scheduling](https://reader035.fdocuments.us/reader035/viewer/2022081520/589a69a61a28ab0b788b4759/html5/thumbnails/114.jpg)