Professional Documents
Culture Documents
Qa - 5
Qa - 5
CPU Scheduler selects from among the processes in memory that are ready to execute, and
allocates the CPU to one of them
Time it takes for the dispatcher to stop one process and start another running: called
Dispatch latency
State 3 Scheduling Criteria: Max CPU utilization, Max Throughput, Min Turnaround time, Min
Waiting time, Min Response time.
If there are n processes 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
With multilevel queue, ready queue is partitioned into separate queues; Each queue has its
own scheduling algorithm
True/False
in nonpreemptive scheduling: Once a process is in the running state, it will continue until it
terminates or blocks itself for I/O or to request some OS service (answer: T)
in preemptive scheduling: Currently running process may be interrupted and moved to ready
state by the OS (answer: T)
With Priority Scheduling: Starvation may exist where low priority processes may never
execute (True)
With multilevel queue, fixed priority scheduling may cause starvation (TRUE)
With Multilevel Feedback Queue: A process can move between the various queues (TRUE)
Select all correct answers:
1. Switches from running to waiting state (ex. I/O request, explicit wait)
Select all decisions under which scheduling is non preemptive (answer 1 & 4)
In FCFS scheduling:
1- The process that requests the CPU first is allocated the CPU first
2- The average waiting time is often quite long
3- Non preemptive
4- Preemptive
5- Convoy effect
6- Optimal scheduling
(Answers: 1, 2, 3, 5)
in RR scheduling:
(Answers: 1, 2, 4, 5)
(Answers: 1, 3, 4)
1- number of queues
2- scheduling algorithms for each queue
3- method used to determine when to upgrade priority
4- method used to determine when to demote priority
5- method used to determine which queue a process will enter when that process
needs service
(Answers: 1, 2, 3, 4, 5)
Exercise
Let us have the following set of procedures P1 … P5 to be scheduled, where the CPU burst is
given in milliseconds, and a small priority number means high priority:
Process Arrival time CPU burst Priority
P1 0 4 3
P2 1 1 2
P3 2 3 2
P4 3 2 1
P5 4 2 1
a. Draw Gantt chart to schedule these processes using each of the following scheduling
algorithms:
• FCFS scheduling
• SJF scheduling –preemptive
• priority scheduling - non preemptive
• RR (time quantum = 2)
b. Calculate the turnaround time, waiting time for each process and for each of the
scheduling algorithms, and fill in the following table:
P1 P2 P3 P4 P5
turnaround time
Average waiting
Average
turnaround
turnaround
turnaround
turnaround
turnaround
time
time
time
time
time
time
FCFS
preemptive
SJF
non-
preemptive
priority
RR
c. Based on the previous table, what is the best algorithm to schedule the given processes
P1…P5 ?