Академический Документы
Профессиональный Документы
Культура Документы
1
Assignment Statement:
Write a menu driven program to implement following CPU scheduling algorithms
1) First come First Serve (FCFS)
2) Shortest Job First (SJF) (Preemptive and non_preemptive)
3) Round Robin (RR)
4) Priority (Preemptive and non_preemptive)
Objectives:
To study the Need for CPU scheduling
To study the comparative study of various CPU scheduling methods
Implementation of CP U Scheduling
Theory:
Need: In multiprogramming environment, multiple processes are maintained in the main
memory. Each process alternates between the using a processor and waiting for I/O to be
completed or for some other event to occur. The processor is kept busy by executing one
process while others wait. The key to multiprogramming is Scheduling. The aim of
Processor scheduling is to assign processes to be executed by the processor over time, in
such a way that meets the system objectives, such as response time, throughput and
processor efficiency.
Types of Scheduling:
Long Term Scheduling: It is invoked when new process is created. This decides
whether to add a new process to the set/pool of processes that are currently active. It
controls the degree of multiprogramming
Medium Term Scheduling: It is a part of swapping function. The decision is taken
whether to add a process to those that are partially or fully available in memory and
therefore available for execution.
Short Term Scheduling: It is the actual decision of which ready processes will be
executed by the processor.
1) First Come First Serve (FCFS):-
This is the simplest CPU scheduling algorithm. It is also known as first in first out (FIFO)
or a strict queuing scheme. As each process becomes ready, it is added at the rear end of
queue. When currently running process finishes, it is removed from the queue and the
next process in the ready queue is selected for execution. FCFS performs much better for
longer processes( having larger CPU burst time).
Characteristics:
Selection Function: max(w), selects the process which is waiting in the ready queue
for maximum time.
Decision Mode : Non_preemptive
Throughput: Not emphasized
Response Time: May be high, especially if there is a large variance in the process
execution times.
Overhead: Minimum
Effect on Processes: Penalizes short and I/O bound processes.
Starvation: No
2
2) Shortest Job First/ Shortest Process Next (SJF/SPN) :- This is a non-preemptive
policy in which the process with the shortest expected processing time is selected next.
Thus a short process will jump to the head of the queue. This type of policy needs to know
or at least estimate the required processing time of each process.
Characteristics:
Selection Function: minimum total service time required by the process, including
time spent in execution so far.
Decision Mode : Non_preemptive
Throughput: High
Response Time: Provides good response time for short processes.
Overhead: Can be high
Effect on Processes: Penalizes long processes.
Starvation: Possible
3
Algorithm : To be written by individual student as per the logic used
Data Structure Used:- Queue implemented using linked list and for Round Robin Circular
linked List
1) For all : Give input such that the processes are not entered as per the arrival time.
2) For all: CPU remains idle
3) For preemptive : Accept input in such a manner that processes get preempted
Round Robin :Test case I
No. Of. Processes: 5
name arrival burst
time time
a 0 1
b 2 1
c 4 2
d 6 3
e 8 2
Enter time quantum for round robin method: 2
Gant chart
a b c d e d
<0 to 1><2 to 3><4 to 6><6 to 8><8 to 10><10 to 11>
Total chart
name arrival finish burst waiting Turnaround
time time time time time
a 0 1 1 0 1
b 2 3 1 0 1
c 4 6 2 0 2
e 8 10 2 0 2
4
d 6 11 3 2 5
Round Robin Test Case 2
name arrival burst
time time
a 0 2
b 1 2
c 2 2
d 7 2
e 8 2
Enter time quantum for round robin method: 1
Total chart
name arrival finish burst waiting Turnaround
time time time time time
a 0 3 2 1 3
b 1 5 2 2 4
c 2 6 2 2 4
d 7 10 2 1 3
e 8 11 2 1 3
FAQ’s :-
5
6