Scheduling Simulation


Work with an LLM to write a simulation in C which analyzes CPU scheduling algorithms. Your program will simulate the following schedulers:

All time units should be an integral number of milliseconds. These milliseconds don't have to literally take a millisecond while running. Don't make things happen in "real time".

Simulate context switches between processes, each of which will require 5 ms. Context switches should not be preempted.


AI Usage

You should use AI to assist in writing this program. Take advantage of Gettysburg's Linc AI Hub.


Command Line Arguments

Your program will need to specify an input file name from the command line and a single flag. The flag is optional on the command line. If it is specified, your program will produce verbose output (see below), otherwise it will produce the default output only.

Suppose you write a program called CPUSim. The command line format would be:

      CPUSim infile -v
where infile is the name of the input file and the optional -v specifies verbose output.

You can specify command line arguments in eclipse by modifying the Run Configurations for your project so you aren't stuck only running from the command line.


Input Format

Your program will read processes from a file. The first line of the file will contain n:the number of processes to simulate which will have a value between 1 and 1000.

There will then be n lines (one for each process) containing 4 integers separated by a single space:

The lines will be ordered by the process's arrival time.

For example the input file might be:
5
1 1 5 65
2 1 10 73
3 1 15 17
4 7 20 128
35 5 25 2

Output Format

There are two output formats that your program should produce. The first is the default format, the second format will be used when your program is run with a -v on the command line. Time units in the output should be in milliseconds, but may be floating point numbers. The output described below should be all that appears on standard output (System.out, cout or stdout). Use standard error for debugging messages (System.err, cerr, stderr).

Default Output

The default output just produces the following statistics for each of the schedulers:

Verbose Output

The verbose output will print out the default output followed by individual process statistics. For each scheduling algorithm you should output information about each process. Each of these should be on its own line which contains the following information:

The line should be just numbers separated by a space with no labels.

The file testOut.txt contains verbose output for the example input above. Your calculations may differ a bit from mine depending on your design and scheduling decisions. They do not need to match exactly.

There is an additional sample input file, procTest.txt and its verbose output procTest_output.txt. You can make other input files using ProcGen.java Java program provided.


Comments

Include thematic comments. I recommend adding these without the assistance of AI to help you understand what the program is doing. These comments will describe in general terms the activities and events surrounding the process structure and life cycle in your simulation. Document what is done to the processes, how they are manipulated, how they change. If your code tells a story, the process is the protagonist.

Thematic comments should begin with a "--", so would use //-- or /*-- to indicate the beginning of a thematic comment.


Submission

Submit the following in Moodle.

Hints and Suggestions

The following are suggestions, not requirements for the assignment.