Here is the assignment:
1. Objective
This assignment will introduce you to CPU scheduling.
2. Specifications
You are to simulate the execution of processes by a computer system with a large memory, one terminal per user, a CPU, and one disk drive. Each process will be described by it's class (REAL-TIME or INTERACTIVE) and its start time followed by a sequence of resource requests.
These resource requests will include CPU requests (CPU), disk reads (DISK0 and terminal accesses (TTY). In addition, all real-time processes will have a DEADLINE, by which they must complete.
Your input will be a sequence of pairs as in (the ones I included at the start)
All time will be expressed in milliseconds.
Your program should maintain separate ready queues for real-time and interactive processes and give absolute priority to real-time processes over interactive processes:
a) Your scheduler should never allocate the CPU to an interactive process as long as there are one or more real-time processes in the ready state.
b) When a real-time process returns to the ready queue and finds that the CPU is currently allocated to an interactive process, the scheduler should take the CPU away from the interactive process and give it to the real-time process. The pre-empted process should return to the end of the ready queue for interactive processes. When this is the case your program should update the duration of the CPU request by subtracting from the orginal duration te time the process has already spent in the running state.
Disk scheduling will be strictly FCFS without any distinction of process classes.
To simplify your life, we will assume that there is enough memory space for all processes, context switch times can be neglected, user think times are included in the terminal access times, and each process reads and writes to a different terminal.
Your program should read its input file name through input redirection as in:
./a.out < input.txt
If by accident, two resources allocations need to be made at the same time, you should allocate the CPU first then the disk then the terminals.
Your program should have on process table with one entry per process containing a process sequence number, the process class, its process arival time and its current statues (READY,RUNNING,WAITING).
It should print out one line of output every time a process starts or terminates. This line should include the process sequence number, its class and the current simulated time in milliseconds.
When all processes in your input stream have completed, your simulator should print a summary report listing:
a) The number of real-time processes that have completed.
b) The percentage of real-time processes that missed their deadline.
c) The number of interactive processes that have completed.
d) The total number of disk accesses.
e) The average duration of a disk access (including the waiting time in the disk queue).
f) The total time elapsed since the start of the first process.
g) The CPU and DISK utilizations, that is, the fraction of time the CPU or the DISK was busy.
So my first instinct was to use a data structure of a queue to implement the FCFS or FIFO scheduling method. From then on, I'm not sure how to implement this. Anybody have any ideas? Thanks for your help in advance. I will greatly appreciate the help.