Sei sulla pagina 1di 19

Operating System

Scheduling
the duology

soni@its-sby.edu

Review
WHY scheduling ?
Multitask Schedule Process

operating system CPU Scheduling

Scheduling Factor

1. CPU utilization - keep the CPU as busy as possible


must be maximized
2. Throughput - number of processes that complete their execution
per time unit
must be maximized
3. Turnaround time - amount of time to execute a particular process
must be minimized
4. Waiting time - amount of time a process has been waiting in the
ready queue
must be minimized
5. Response time - amount of time it takes from when a request was
submitted until the first response is produced, not output (for
timesharing environment)
must be minimized
operating system CPU Scheduling

SCHEDULING METHOD
FIRST COME FIRST SERVE (FCFS / FIFO)
SORTHEST JOB FIRST (SJF)
PRIORITY BASED
ROUND ROBIN

operating system CPU Scheduling

First-Come, First-Served (FCFS)


Proces

Burst
time

Service
Time

Completion
time

p1

24

24

p2

24

27

p3

27

30

processes arrive in the order: P1, P2, P3

Waiting time for P1= 0; P2= 24; P3 = 27


Average waiting time: (0 + 24 + 27)/3 = 17
Proces

Burst
time

Service
Time

Completion
time

p1

24

??

??

p2

??

??

p3

??

??

processes arrive in the order: P2, P3, P1

Waiting time for P1= 6; P2= 0; P3 = 3


Average waiting time: (6 + 0 + 3)/3 = 3
Conclusion ?

CONVOY EFFECT
short process behind long process

operating system CPU Scheduling

SORTHEST JOB FIRST (SJF)

Non - Preemptive
Waiting time :
p1=0 ; p2=6; p3=3; p4=7
Average = (0 + 6 + 3 + 7)/4 = 4 ms

Preemptive

Waiting time :
p1=9 ; p2=1; p3=0; p4=2
Average = (9 + 1 + 0 + 2)/4 = 3 ms
Best approach to minimize waiting time.
Impossible to implement
Processer should know in advance how much time process will take.
operating system CPU Scheduling

PRIORITY BASED
Waiting time :
p1=6 ; p2=0; p3=16; p4=18; p5=1
Average = (6 + 0 +16 + 18 + 1)/5 = 8.2 ms

Each process is assigned a priority. Process with highest priority is to be executed first and so on.
Processes with same priority are executed on FCFS
Priority can be decided based on memory requirements, time requirements or any other resource
requirement.

Round Robin Scheduling


Each process is provided a fix time to execute called quantum Q.
Once a process is executed for given time period. Process is preempted
and other process executes for given time period.
If there are nprocesses in the ready queue and the time quantum is Q,
then each process gets 1/n of the CPU time in chunks of at most Q
time units at once. No process waits more than (n-1)Q time units.
Performance
If Q large -> FIFO
If Q small -> overhead is too high
operating system CPU Scheduling

RR with Quantum - 4
Proces

Execute
time

p1

24

p2

p3

operating system CPU Scheduling

Multi Queue Scheduling


Multiple queues are maintained for processes.
Each queue can have its own scheduling algorithms.
Priorities are assigned to each queue.

operating system CPU Scheduling

10

Example of Multilevel
Three queues:
Q0 - RR with Q 8 milliseconds
Q1 - RR with Q 16 milliseconds
Q2 FCFS
A new job enters queue Q0 which is served FCFS. When it gains CPU, job receives 8
milliseconds. If it does not finish in 8 milliseconds, job is moved to queue Q1 .
At Q1 job is again served FCFS and receives 16 additional milliseconds. If it still does
not complete, it is preempted and moved to queue Q2

operating system CPU Scheduling

11

References
1. Abraham Silberschatz, Peter Baer Galvin, Greg
Gagne, Operating System Concepts With Java,
Wiley

operating system

12

Assignment 3
Use Software OS Simulator OS SIM for simulating CPU/Process
Scheduling : FCFS, SJF, Priority, and RR (available at elearning)
Each Student will get his/her unique data. 10 processes for each
student. It has various priority for priority-based. And 5 scenarios for
RR based on the quantum time.
(see googledocs spreadsheet Sheet CPU Scheduling)
Make sure you understand the software before insert the data
All that I can say is GOOD LUCK

SUBMISSION
Submit your report to elearning
REPORT must contain :
1. Cover page : Student id, and bla bla bla
2. Software utilization. How to add, process, and get the result
(including some screenshots)
3. Analyze the result based on each scheduling method
4. Analyze more by summarizing or comparing scheduling
methods
Give your best analysis (because you would be a systems
analyst)
Format : AS3-<NRP>.pdf (eg. AS3-5214100010.pdf)
operating system - process

18

But its not over yet Assignment 4


Every week there will be presentation about operating system or
hardware or computer system HOW DOES IT WORK?, presented
by student (10 minutes).
One or two students per week will randomly selected
Student must present unique topic, submit your topic at once to
google form before other students took it (link will be provided at
elearning)
Make the presentation but submit in pdf
Format; AS4-<NRP>.pdf (eg. AS4-5214100010.pdf)
Due date : next week

Potrebbero piacerti anche