Lab 4: CPU Scheduler


Due Dates: Assignment IDs:

Lab description

Write a CPU scheduler for the following algorithms: The program must use a process data filename provided on the command-line. The process data file has have four columns of numbers:
  1. Process ID
  2. Arrival time
  3. CPU burst time
  4. Priority (higher = higher priority)
Additionally, the simulator must output every time the CPU scheduler chooses a process to run with the following syntax:
ALGORITHM_NAME: Scheduling process ID NUMBER. For testing purposes, use at least the following two files: The process data file may have any information for any number of processes up to 10. Finally, name the source code file lab4.cpp.

Pseudocode

For this lab, design your implementation using pseudocode. Additionally, in the pseudo code document, indicate the type of data structures that you'll use to keep track of the process information.

Example Execution

$ ./lab4 processData1.txt
FCFS: Scheduling process ID 1
FCFS: Scheduling process ID 2
FCFS: Scheduling process ID 3
FCFS: Scheduling process ID 4
FCFS: Scheduling process ID 5
SJF: Scheduling process ID 1
SJF: Scheduling process ID 2
SJF: Scheduling process ID 4
SJF: Scheduling process ID 3
SJF: Scheduling process ID 5
STRF: Scheduling process ID 1
STRF: Scheduling process ID 2
STRF: Scheduling process ID 3
STRF: Scheduling process ID 3
STRF: Scheduling process ID 4
STRF: Scheduling process ID 1
STRF: Scheduling process ID 5
PRIORITY: Scheduling process ID 1
PRIORITY: Scheduling process ID 4
PRIORITY: Scheduling process ID 3
PRIORITY: Scheduling process ID 5
PRIORITY: Scheduling process ID 2
PREEMPTIVE PRIORITY: Scheduling process ID 1
PREEMPTIVE PRIORITY: Scheduling process ID 1
PREEMPTIVE PRIORITY: Scheduling process ID 3
PREEMPTIVE PRIORITY: Scheduling process ID 4
PREEMPTIVE PRIORITY: Scheduling process ID 3
PREEMPTIVE PRIORITY: Scheduling process ID 1
PREEMPTIVE PRIORITY: Scheduling process ID 5
PREEMPTIVE PRIORITY: Scheduling process ID 2
ROUND-ROBIN: Scheduling process ID 1
ROUND-ROBIN: Scheduling process ID 2
ROUND-ROBIN: Scheduling process ID 3
ROUND-ROBIN: Scheduling process ID 1
ROUND-ROBIN: Scheduling process ID 4
ROUND-ROBIN: Scheduling process ID 5
ROUND-ROBIN: Scheduling process ID 1
ROUND-ROBIN: Scheduling process ID 5
ROUND-ROBIN: Scheduling process ID 1
ROUND-ROBIN: Scheduling process ID 5
ROUND-ROBIN: Scheduling process ID 1
ROUND-ROBIN: Scheduling process ID 5
ROUND-ROBIN: Scheduling process ID 5

Submission

Submit the pseudo code and source code files using the handin program. For example, to submit the pseudo code for this lab, type the following in a terminal exactly as it appears:
  handin  lab4-pseudocode  lab4-pseudocode.txt

For the program for this lab, type the following in a terminal exactly as it appears:
  handin  lab4  lab4.cpp

Alternatively, you can submit the assignment from any computer via PeerSpace. After successfully logging into PeerSpace, go to Tools, then Assignments. Click on the Submit link.

Rubric: Pseudocode

Points          Item
----------      --------------------------------------------------------------
_____ /   5  	Outlines major design
_____ /   5  	Limited amount of actual code
_____ /   5 	Indicates data structures

_____ /  15

Rubric: Program

Points          Item
----------      --------------------------------------------------------------
_____ /   5  	Uses filename from command-line
_____ /   5 	Correct syntax for output (ALGORITHM_NAME: Scheduling process ID NUMBER)
_____ /  15	Correctly outputs sequence for FCFS
_____ /  15	Correctly outputs sequence for SJF
_____ /  15	Correctly outputs sequence for STRF
_____ /  15	Correctly outputs sequence for Priority
_____ /  15	Correctly outputs sequence for Preemptive Priority
_____ /  15	Correctly outputs sequence for Round-robin

_____ / 100


Hints

  1. For more information on pseudo code, see Wikipedia's page and this short video.