Os PRT 4
Os PRT 4
Problem Statement:
Simulate any two of the following CPU Scheduling Algorithms (One each from preemptive and
non-preemptive types)
a. FCFS
b. SJF
c. Round Robin
d. Priority
Aim:
Theory:
CPU scheduling is the task of selecting a waiting process from the ready queue and allocating the CPU to
it. The CPU is allocated to the selected process by the dispatcher (It is the module that gives control of
the CPU to the processes by short-term scheduler).
Scheduling is a fundamental operating system function. In a single processor system, only one process
can run at a time; any other process must wait until the CPU is free and can be rescheduled. The
objective of multiprogramming is to have some process running always, to maximize CPU utilization.
CPU scheduling decisions may take place under the following four circumstances:
1. When a process switches from the running state to the waiting state
2. When a process switches from the running state to the ready state.
3. When a process switches from the waiting state to the ready state.
1. NON-PREEMPTIVE
2. PREEMPTIVE
1. NON-PREEMPTIVE: Under this scheduling, once the CPU has been allocated to a process, the process
keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.
2. PREEMPTIVE: Under this class of scheduling scheme, the process may be preempted by the scheduler
after allocating the CPU to it, so as to allocate the CPU to another deserving process.
SCHEDULING CRITERIA:
1. CPU utilization: It is the fraction of time for which CPU is busy. It can range from 0-100%.
3. Turnaround time: It is the sum of the periods spent by a process waiting to get into memory, waiting
in the ready queue, executing on the CPU, and doing I/O .
4. Waiting time: It is the sum of the periods spent waiting in the ready queue.
5. Response time: Time from the submission of a request until the first response is produced. It is
desirable to maximize CPU utilization and Throughput and minimize Turnaround time, waiting time and
Response time.
NON-PREEMPTIVE PREEMPTIVE
FIRST COME FIRST SERVE (FCFS) SHORTES REMAINING TIME NEXT (SRTN)
SHORTEST JOB FIRST (SJF) ROUND ROBIN
Non- PREMPTIVE PRIORITY PREMPTIVE PRIORITY
------------------------------------------------------------------------------------------------------------------------------------------
-
………………………
Output:
Gantt Charts
…………………………
Output:
Gantt Charts
Average waiting time
Conclusion:
………………………………………………