Introduction

CPU scheduling is a process of determining which processes run when there are multiple runnable processes. The goal of CPU scheduling is faster computation which is also fair and efficient.

General Instructions

In this assignment, you will create a PCB (Process Control Block) class which holds the information of a process such as id, arrival time, start time, end time and burst time(job time). All possible class variables should be initialized in the constructor by reading the input file. Hence number of PCB objects is determined by the input file.

Create a Scheduler class. It should enqueue the PCB objects into a STL Queue based on the arrival time and dequeue a PCB object whenever the CPU is free. Calculate whether CPU is free based on the allocation time + burst time of the previous PCB object. Assume CPU is free for the initial case.

To Summarize the steps

  • Open input data source (Use of stringstream will bag you a bonus point)
  • Initialize clock (to zero)
  • Increment clock counter
  • Enqueue process (if any)
  • Check CPU availability. If available, dequeue one of the available process to the CPU based on the shortest burst time(job time)
  • If process in in CPU is done, free the CPU.
  • Repeat 3-6 till PCB queue and CPU are both empty
  • Print the following summary for each process.
    • Arrival Time (Time at which the process arrives in the ready queue.)
    • Completion Time (Time at which process completes its execution)
    • Burst Time(Time required by a process for CPU execution)
    • Turn Around Time (Turn Around Time = Completion Time - Arrival Time + 1)
    • Waiting Time (Waiting Time = Turn Around Time - Burst Time)

Programming concepts that are expected in the solution:

  • The program should consist of at least 3 modules:
    • To create PCB
    • To implement Scheduler
    • To test the Scheduler
  • Following good object oriented programming practices
    • Keep the data members private
    • Accessor function should be declared to set and get the private data if needed.
  • Use operator << overloading to print the summary of PCB
  • Use appropriate STL container you should include a short paragraph justifying the use of the your chosen STL container a better choice will be awarded better grades!

Sample Input

ID Arrival Burst
#1 1 8
#2 3 2
#3 4 6
#4 8 2
#5 12 1

Sample Output

At clock 0: CPU Available
PCB Queue (empty)
At clock 1: PCB #1 enqueued
PCB #1 dequeued
CPU Busy(PCB #1 [1/8] )
PCB Queue (empty)
At clock 2: CPU Busy(PCB #1 [2/8])
PCB Queue (empty)
At clock 3: PCB #2 enqueued
CPU Busy(PCB #1 [3/8])
PCB Queue (PCB #2)
At clock 4: PCB #3 enqueued
CPU Busy(PCB #1 [4/8])
PCB Queue (PCB #2, PCB #3)
At clock 5: CPU Busy(PCB #1 [5/8])
PCB Queue (PCB #2, PCB #3)
At clock 6: CPU Busy(PCB #1 [6/8])
PCB Queue (PCB #2, PCB #3)
At clock 7: CPU Busy(PCB #1 [7/8])
PCB Queue (PCB #2, PCB #3)
At clock 8: PCB #4 enqueued
PCB #1 done
CPU available
PCB Queue (PCB #2, PCB #3, PCB #4)
At clock 9: PCB #2 dequeued
CPU Busy(PCB #2 [1/2])
PCB Queue (PCB #3, PCB #4)
At clock 10: PCB #2 done
CPU Available
PCB Queue (PCB #3, PCB #4)
At clock 11: PCB #4 dequeued
CPU Busy(PCB #4 [1/2])
PCB Queue (PCB #3)
At clock 12: PCB #5 enqueued
PCB #4 done
CPU Available
PCB Queue (PCB #3, PCB #5)
At clock 13: PCB #5 dequeued
PCB #5 done
CPU Available
PCB Queue (PCB #3)
At clock 14: PCB #3 dequeued
CPU Busy(PCB #3 [1/6])
PCB Queue (Empty)
At clock 15: CPU Busy(PCB #3 [2/6])
PCB Queue (Empty)
At clock 16: CPU Busy(PCB #3 [3/6])
PCB Queue (Empty)
At clock 17: CPU Busy(PCB #3 [4/6])
PCB Queue (Empty)
At clock 18: CPU Busy(PCB #3 [5/6])
PCB Queue (Empty)
At clock 19: PCB #3 done
CPU Available
PCB Queue (Empty)
At clock 20: CPU Available
PCB Queue (Empty)

Summary:
ID Arrival Burst Completion Turnaround Waiting
#1 1 8 8 8 0
#2 3 2 10 8 6
#3 4 6 19 16 10
#4 8 2 12 5 3
#5 12 1 13 2 1

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.