Round Robin (RR) scheduler which prints gantt, cpu, input and output chart along with calculating total and average for turn around, waiting and response time for each process.
Round Robin (RR) is a preemptive cpu scheduler in which processes run for a constant time quantum in turns. It is implemented using a FIFO queue.
[number of processes]
[pid] [arrival time] [priority] [share] C [burst] I/O [burst] C [burst] ........... -1
....
[pid] [arrival time] [priority] [share] C [burst] I/O [burst] C [burst] .......... -1
First line describes number of processes.
Then Each of the next N lines describe : -
[pid] : process id.
[arrival time] : time this process was put into ready queue.
[priority] : priority assigned to a process. A lower value means higher priority
[share] : % of tickets assigned in lottery (proportional share) scheduling.
This is followed by sequence of bursts. Before each burst interval, there is a character indicating type of burst.
C : stands for CPU
I : stands for Input
O : stands for output device
-1 : indicates end of trace file
For Round Robin scheduling, time quantum shall be one.
We are assuming one CPU, one Input device and one output device.
Input/output devices follow first come first serve policy i.e. if a process is assigned an input/output device, this device can not be assigned to any other process till its burst is over.
3 1 0 2 1 C 2 I 2 C 3 -1 2 2 0 2 C 4 O 2 C 4 -1 3 0 1 1 C 6 I 4 C 2 -1
Use g++ rr.cpp
to compile and ./a.out
to run on linux
rr_codespeedy
├── Process.h ( header file containing helper methods)
├── process.dat ( input file )
└── rr.cpp ( C++ rr scheduler program )
0 directories, 3 files
C++ 11 or later
Submitted by Abdullah Jamal (Abdullahj)
Download packets of source code on Coders Packet
Comments