Assigned Date: Wednesday, Feb. 8, 2012
Due Date: Monday, Feb. 20, 2012
Due Time: 10:50am
Last modified on February 20, 2012, at 12:16 PM (see updates)
This is a solo assignment. You must work alone.
This assignment focuses on Process Management with C, and in particular:
Create a process management simulation in C that implements a First Come First Serve (FCFS) scheduler.
Read in process information from an ASCII file. The name of the file will be provided as input to your program, using C command-line arguments.
For example, see [1].
The first line of the input file contains the number of processes that will be used in the simulation.
Each subsequent line of the input file will contain 3 integers describing a single process to be run. The first integer is the process ID, the second integer is the arrival time of the process, and the third integer is the required execution time of the process (remember, we are simulating execution). You should ignore anything past the third integer on each line (e.g., we may use this feature to implement input-file comments). The file may contain an arbitrary number of processes.
Example file contents:
You may only assume that processes are sorted by arrival time.
Processes and their related information should be stored in ProcessBlockRecords (PBR) organized as a queue in order of their arrival time. The PBRs should be represented as C structs, and the queue as a dynamic array.
Instead of maintaining actual time in your program, you should use a counter and treat every increment made as the passing of 1 second.
Simulation time starts at 0 seconds.
In a real system, each process would perform some sort of work while executing, but, for simplicity, this simulation will omit this.
For now, implement First Come First Serve (FCFS) to allocate the CPU to the processes. There will be no time quantum/slice, therefore the implemented algorithm will be non-preemptive.
Your program should output the following for each process:
where n
, p
, q
are int values.
Upon completion of the simulation, i.e., when all processes have finished executing, your program should output the following statistics:
where x
, y
, z
are float values.
Average wait time: Average (across all processes) of elapsed time between a process' arrival time and the moment it is allocated the CPU.
Average turnaround time: Average (across all processes) of elapsed time between a process' arrival time and its completion.
Average execution time: Average of all the processes' run times.
So, for the above input example, the output should be:
Follow the Golden Rule of Style: "A program should be as easy for a human being to read and understand as it is for a computer to execute." [2]
In general, you should comment any variable, obscure statement, block of code, etc. you create.
Also, you should comment why something is being done, e.g.,
as opposed to how it is done, e.g.,
Finally, your code should always include opening comments as follows.
(NOTE: Angle brackets signify information that needs to be filled out. Remove the angle brackets!)
You will submit your assignment via the stono submit
command, as follows:
% submit csci340 hmwk2 fcfs.c
or as follows (if you include a C header file):
% submit csci340 hmwk2 fcfs.c fcfs.h
No other submission mechanism will be accepted (e.g., email).
Your assignment will be graded based on the documentation, formatting, and correctness of your source code. Also the completeness / thoroughness of your work, and how well you followed the homework instructions.