Work with an LLM to write a simulation in C which analyzes CPU scheduling algorithms. Your program will simulate the following schedulers:
First Come First Serve
Preemptive Shortest Job First
Priority (preemptive)
Round Robin with quantum=20.
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.
You should use AI to assist in writing this program. Take advantage of Gettysburg's Linc AI Hub.
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 -vwhere 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.
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:
5 1 1 5 65 2 1 10 73 3 1 15 17 4 7 20 128 35 5 25 2
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.
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.
Start early.
Make each iteration of an outer loop represent 1 msec. Each iteration should update each process's statistics and make any state changes necessary.
This is not an exercise in syntax and semantics, it is all about the simulation. If you find yourself getting caught up in details, stop and ask for help.
Don't run with scissors.