LAB #5 CPU Scheduling Algorithms-1: Objective Theory
LAB #5 CPU Scheduling Algorithms-1: Objective Theory
LAB #5
Theory
Scheduling is the task of operating system in which processes are given access to system
resources. Scheduling is a fundamental operating system function that determines which
process run, when there are multiple processes in ready queue. CPU scheduling is important
because it impacts resource utilization and other performance parameters.
Scheduling Criteria
Different CPU scheduling algorithms have different properties and may favor one class of
processes over another. In choosing which algorithm to use in a particular situation, we must
consider the different properties of the various algorithms.
CPU Utilization: We want to keep the CPU as busy as possible. CPU utilization may range
from 0 to 100 percent. In a real system, it should range from 40 percent (for a lightly loaded
system) to 90 percent (for a heavily used system).
Throughput: If the CPU is busy executing process, then work is being done. One calculate
of work is the number of processes that are completed per time unit, called throughput. For
long processes, this rate may be one process per hour; for short transactions, throughput
might be 10 processes per second.
Turnaround time: From the point of view of a particular process, the important criterion is
how long it takes to execute that process. The interval from the time of submission of a
process to the time of completion is the turnaround time. Turnaround time is the sum of the
periods spent waiting to get into memory, waiting in the ready queue, executing on the CPU,
and doing I/O.
Waiting Time: The CPU scheduling algorithm does not affect the amount of time during
which a procedure executes or does I/O; it affects only the amount of time that a process
spends waiting in the prepared queue. Waiting time is the sum of the periods spent waiting in
the ready queue.
Response time: In an interactive system, turnaround time may not be the best criterion.
Often, a process can produce some output fairly easy, and can continue computing new
results while earlier results are being output to the user. Thus, another measure is the time
from the submission of a request until the first response is produced. This measure, called
response time, is the time that it takes to start responding, but not the time that it takes to
output that response. The turnaround time is generally incomplete by the speed of output
device.
Scheduling Algorithms
A Process Scheduler schedules different processes to be assigned to the CPU based on
particular scheduling algorithms. There are six popular process scheduling algorithms which
we are implementing in this lab:
Operating System 27
SWE-204L: OPERATING SYSTEM SSUET/QR/114
Exercise
1. Write a program which takes as an argument at least 10 CPU Brust time. Calculate CPU
utilization, average waiting time, turnaround time and response time using SJF(Non-Preemptive)
and SJF(Preemptive). Display a text-based Gantt chat on the screen.
2. Write a program which takes as an argument at least 15 CPU Brust time. Calculate CPU
utilization, average waiting time, turnaround time and response time using FCFS. Display a text-
based Gantt chat on the screen.
Operating System 28