0% found this document useful (0 votes)
29 views

Discussion on CPU scheduling

Discussion on CPU scheduling

Uploaded by

himanshujhaa4262
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Discussion on CPU scheduling

Discussion on CPU scheduling

Uploaded by

himanshujhaa4262
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Discussion Questions on Scheduling Policies

1. What is a workload? What scheduling metrics are discussed till now? Can
you think of others?
2. What is the difference between preemptive and non-preemptive schedulers and what
are their drawbacks?
3. What is FIFO? what data structures would we use to implement it? What
drawback(s) does FIFO have?
4. How does SJF improve over FIFO? What are its limitations?
5. Is SJF fair? What if there are a lot of small jobs and a few long ones?
6. How does STCF improve over SJF? Is STCF fair?
7. What is response time? How well does STCF perform to minimize response
time?
8. What is a time slice? Why don't we make the time slice really small (1
instruction)?
9. How does RR minimize response time? What is the max response time for a
newly arrived job?
10. Is RR fair? How does RR performs in terms of turnaround-time?
11. How does I/O affect our model of CPU scheduling? Why should we treat jobs
that do I/O as a series of separate jobs? Are there any disadvantages to do this?
12. What are the goals of MLFQ? How is an MLFQ scheduler built?
13. Where do new jobs enter MLFQ (to what end)? What happens when a job uses its
entire time slice?
14. How does MLFQ approximate SJF? Is MLFQ fair?
15. What is starvation? Is it possible to starve in MLFQ? why (not)?
16. What is "gaming the system/scheduler"? Is it possible in MLFQ?
17. Does the anti-gaming rule 4 stop cheating & minimize TT for short jobs? What if
my job legitimately uses just about a whole timeslice and then does I/0?
18. What is the longest a process can go without being scheduled in MLFQ? Is this a
hard bound (no because of # of processes)

(….PTO/scroll for practice problems)


Practice Problems

1. Consider the following three processes that arrive in a system at the specified
times, along with the duration of their CPU bursts. Process P1 arrives at time
t=0, and has a CPU burst of 10 time units. P2 arrives at t=2, and has a CPU
burst of 2 units. P3 arrives at t=3, and has a CPU burst of 3 units. Assume that
the processes execute only once for the duration of their CPU burst, and
terminate immediately. Calculate the time of completion of the three
processes under each of the following scheduling policies. For each policy,
you must state the completion time of all three processes, P1, P2, and P3.
Assume there are no other processes in the scheduler’s queue. For the
preemptive policies, assume that a running process can be immediately
preempted as soon as the new process arrives (if the policy should decide to
premempt).

(a) First Come First Serve


(b) Shortest Job First (non-preemptive)
(c) Shortest Remaining Time First (preemptive)
(d) Round robin (preemptive) with a time slice of (atmost) 5 units per process

2. Consider the following set of processes, with the length of the CPU burst given in
milliseconds.

Process Burst Time Priority


P1 10 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5 all at time 0.

a) Draw four Gantt charts that illustrate the execution of these processes using the
follow- ing scheduling algorithms: FCFS, SJF, non-preemptive priority (a smaller
priority number implies a higher priority), and RR (quantum = 1).
b) What is the turnaround time of each process for each of the scheduling
algorithms in part a?
c) What is the waiting time of each process for each of the scheduling
algorithms in part a?
d) Which of the algorithms om part a results in the minimum average waiting
time (over all processes)?

3. Consider the following set of processes, with the length of the CPU burst and
arrival time given in milliseconds.
Process Burst Time Arrival time
P1 8 0
P2 4 0.4
P3 1 1

a) Draw four Gantt charts that illustrate the execution of these processes using the
following scheduling algorithms: FCFS, SJF, Clairvoyant SJF (the algorithm can
look into the future and wait for a shorter process that will arrive).
b) What is the turnaround time of each process for each of the scheduling
algorithms in part a?
c) What is the waiting time of each process for each of the scheduling algorithms
in part a?
d) Which of the algorithms from part a results in the minimum average waiting
time (over all processes)?
4. In the context of Round Robin (RR) scheduling, answer the following:
a) What are the major strengths and weaknesses of the RR approach?
b) How does reducing the time quanta of RR change its behavior/performance?
c) If a random job is picked to run next at each quantum, how would that change
its performance (is it better, worse, or quite similar)?

5. Consider a variant of the Round Robin (RR) scheduling algorithm in which the
entries in the ready queue are pointers to the PCBs

a) What would be the effect of putting two pointers to the same process in the ready
queue?
b) What would be major advantages and disadvantages of this scheme?

c) How would you modify the basic RR algorithm to achieve the same effect
without the duplicate pointers?

6. In a particular workload given in table below, Jobs A and B are completely CPU-
bound processes. Job C requires 1 unit of CPU followed by 4 time units of I/O, in a
pattern repeated thrice, followed by 1 unit of CPU. For each job sequence, C stands
for CPU and I stands for I/O.
Job ID Arrival Execution pattern Length
A 0 CCCCCCCCCCC 10
B 1 CCCCCCCCCCCC 11
C 2 CIIIICIIIICIIIIC 16

An example job schedule of a FIFO scheduling policy (without preemption)


would look like: AAAAAAAAAABBBBBBBBBBBCxxxxCxxxxCxxxxC
where x represents an idle CPU. Note here Job A began at time 0 and finished at
time 10. Determine the job schedule for each of the following scheduling policies
(a) to (c)
(a) Round Robin with a 1-unit time quantum
(b) SJF
(c) STCF
(d) From the given workload, which of the above scheduling policies
maximize(s) CPU utilization as well as most suited for interactive jobs? If there
is more than one, explain the primary advantage of using one over the other.

7. Consider a multilevel feedback queue scheduler with three queues, numbered Q0 to


Q2 (Q0 being the highest priority queue) and time quantum of 4 ms, 8 ms and 16ms
respectively. If a process arrives in a higher priority queue, it will preempt any
process in lower queue. Suppose that the following processes arrive for executing at
the times indicated (numbers are in milliseconds). Assume no priority boosting.
(a) Draw the scheduling of these processes with respect to time on X axis and
different Queue’s on the Y axis.
(b) Compute the average waiting and turnaround time.

Process Arrival Time Burst Time


P1 0 16
P2 14 6
P3 19 3
P4 20 1
P5 21 14

8. Figure below shows the timeline of how two CPU-bound (no I/O) jobs, A and B
run over time on an OS using MLFQ (multi-level feedback queue) scheduler.
Assume no other jobs are present in the system. Note that in the timeline after
225 till 500, A and B continue to get scheduled alternately with time quantum of
55 milliseconds and after 500milliseconds, the entire pattern repeats again,
indefinitely (until the jobs are done)

(a) How many queues do you think there are in this MLFQ scheduler?
(b) How long is the time slice at the top-most (high priority) and the bottom-most
(low priority) queue?
(d) How often do processes get moved back to the topmost queue?
(e) Why does the scheduling policy MLFQ move processes to higher priority levels
(i.e., the topmost queue) sometimes?

You might also like