Skip to content

This program simulates a few basic CPU scheduling algorithms (FCFS, SJF, and RR)

License

Notifications You must be signed in to change notification settings

pijner/CPU_Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CPU_Simulation

This program simulates a few basic CPU scheduling algorithms

Algorithms included

  • First come first serve (FCFS)
  • Shortest job first (SJF)
  • Round robin (RR)

The memory can hold a maximum of 10 jobs at a time in the job queue. A job is loaded into memory by creating a Process Control Block (PCB) for the process and inserting it into the Ready queue. Once a job is completed, it is removed from the job queue and another job is loaded. It can be assumed that there's I/O activity between CPU bursts for each process. A process performing I/O is places in the blocked queue and is moved back into the ready queue once the I/O time (10 time units) is complete.

Usage

$ cpusim <algorithm> [time quantum if algorithm == RR] <File name for Jobs>

The algorithm can be FCFS, SJF, or RR
If the algorithm is RR, the time quantum must be specified
The file name for jobs is the name of the file that includes a list of all jobs (in this case it is JobQueue.txt

Input

The input in this case is JobQueue.txt which consists of all the jobs to be simulated. A job described by the following
job_ID arrival_Time cpu_Bursts_Required cpu_Bursts_Sequence

Output

After each job termination, the following is printed:

  • job ID
  • arrival time (time after start that job arrived to the system)
  • completion time (time after start that job was completed)
  • processing time (total time spent in CPU control + 10 units per I/O task)
  • waiting time
  • turnaround time
  • number of CPU bursts used by the job

After every 200 time units, the following is printed:

  • number of jobs in ready queue
  • number of jobs in the blocked queue
  • number of jobs completed

After completion of all jobs, the following is printed:

  • scheduling algorithm used
  • number of CPU clock cycles elapsed
  • average processing time
  • average waiting time
  • average turnaround time
  • average number of CPU bursts used by a job

About

This program simulates a few basic CPU scheduling algorithms (FCFS, SJF, and RR)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages