Exercise#1_CPU_Scheduling
Exercise#1_CPU_Scheduling
EXERCISE#1 - CPU
HOMEWORK#2 SCHEDULING
– SCHEDULING
1. Consider five processes (P0 à P4) with arrival times and CPU burst times as follows :
Process Arrival time CPU burst time
P0 0 6
P1 3 11
P2 5 9
P3 6 4
P4 6 3
a) Draw Gantt charts that illustrate the execution of these processes using the following scheduling
algorithms: FCFS, RR (time quantum = 3) and RR (time quantum = 6), SJF.
b) For each of the scheduling algorithms specified in part a, calculate the turnaround time of each
process and then the average turnaround time.
c) For each of the scheduling algorithms specified in part a, calculate the waiting time of each
process and then the average waiting time.
2. Consider five processes (P0 à P4) coming to the ready queue in the order P0, P1, P2, P3, P4, with CPU
burst times and priorities (a small integer indicates a high priority) as follows:
Process CPU burst time Priority
P0 4 5
P1 4 5
P2 2 2
P3 2 2
P4 1 1
Assume that the order of execution of these processes presented as follows: P0, P1, P2, P3, P4, P0, P1.
Which scheduling algorithms (FCFS, RR, SJF, Priority, …) may be used to schedule these processes?
Explain your answer.
RR (q = 2 hay q = 3) vì
nếu q = 3 hay q = 2 thì
nó sẽ quay lại P0 và P1
3. Consider the following scheduling algorithms:
- FCFS
- SJF
- Round Robin
- Priority Scheduling
Which of these algorithms could result in starvation? Which processes could be in starvation
situation for each of the scheduling algorithms? How to prevent this situation?
4. Consider five processes (P0 à P4) with arrival times, CPU burst times, and priorities (a small integer
indicates a high priority) as follows:
Process Arrival time CPU burst time Priority
P0 0 5 6
P1 1 6 3
P2 2 7 5
P3 2 9 3
P4 3 2 4
a) Draw Gantt charts that illustrate the execution of these processes using the following scheduling
algorithms: preemptive priority scheduling, nonpreemtive priority scheduling.
b) Calculate the average turnaround time and waiting time for each of the scheduling algorithms?
FIT – HCMUS
5. A POSIX system schedules process with preemptive priority scheduling. Each process is assigned a
priority value from 0 to 29 (29 being the highest priority) and classified into one of three following
classes:
- SCHED_FIFO used for scheduling for real-time processes according to FCFS algorithm (the
highest priority process will be placed at the head of the ready queue);
- SCHED_RR used for scheduling real-time round-robin processes according to RR algorithm with
time quantum = 1 (the highest priority process will be placed at the head of the ready queue);
- SCHED_OTHER used for scheduling other kinds of processes (the highest priority process will
be placed at the head of the ready queue).
Processes of class SCHED_FIFO are the most important, therefore no other process can be executed
if there is at least one process of class SCHED_FIFO in the system. Similarly, processes of class
SCHED_RR are more important than ones of class SCHED_OTHER, therefore processes of
SCHED_OTHER must be blocked until all processes SCHED_RR finish execution.
Consider a set of processes presented in the following table:
Draw Gantt chart that illustrates the execution of these processes within 30 units of time.
FIT – HCMUS