0% found this document useful (0 votes)
7 views2 pages

Exercise#1_CPU_Scheduling

The document outlines a series of exercises related to CPU scheduling algorithms for five processes, including tasks for drawing Gantt charts and calculating turnaround and waiting times using various algorithms such as FCFS, RR, SJF, and Priority Scheduling. It also discusses potential starvation issues in scheduling and presents a scenario involving POSIX system scheduling classes. Additionally, it includes a set of processes with different classes and priorities for which Gantt charts are to be drawn.
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)
7 views2 pages

Exercise#1_CPU_Scheduling

The document outlines a series of exercises related to CPU scheduling algorithms for five processes, including tasks for drawing Gantt charts and calculating turnaround and waiting times using various algorithms such as FCFS, RR, SJF, and Priority Scheduling. It also discusses potential starvation issues in scheduling and presents a scenario involving POSIX system scheduling classes. Additionally, it includes a set of processes with different classes and priorities for which Gantt charts are to be drawn.
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/ 2

Operating System Course

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:

Process Class Recurring Period First Arrival CPU Priority


process Time burst
f1 SCHED_FIFO Yes 8 0 1 28
f2 SCHED_FIFO Yes 7 0 2 26
f3 SCHED_FIFO - - 5 4 20
f4 SCHED_FIFO - - 4 3 20
r1 SCHED_RR - - 3 3 10
r2 SCHED_RR - - 4 3 10
o SCHED_OTHER - - 0 1 0

Draw Gantt chart that illustrates the execution of these processes within 30 units of time.

FIT – HCMUS

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy