ENES BAŞER - 2020400141
The main.c file contains the main logic for a process scheduling simulation. It reads process data from a file, populates the process instructions, sorts the processes, and then simulates their execution.
-
Process: Holding fields for processes. It would be a good choice to operaitons with fields of corresponding structs. -
Instruction: Instruction has some fields like duration name. And also it is useful to use this structure inProcessstruct -
enum: Defined for purpose of type of the process wheter they areGOLD,PLATINUM ,SILVER
-
procs: An array ofProcstructures, each representing a process to be scheduled. -
count: A counter for the number of processes read from the file. -
curr_time: The current time in the simulation. -
turnaround: A variable to hold the turnaround time. -
allFinished: A boolean flag to check if all processes have finished execution. -
test,temp_count,init: Temporary variables used in the simulation loop.
-
populateProcessInstructions(&procs[i]): Populates the instructions for the processprocs[i]. -
qsort(procs, count, sizeof(struct Proc), compareProcs): Sorts theprocsarray using thecompareProcsfunction. -
compareProcs: A function used to compare twoProcstructures (not shown in the provided code).
-
The program reads process data from a file and stores it in the
procsarray. If more than 10 processes are read, the program only keeps the first 10 and discards the rest. -
The program populates the instructions for each process.
-
The
procsarray is sorted to handle scheduling priority . (Refretence to qsort and custom compareTo function) -
The program enters a simulation loop where it simulates the execution of the processes. It handles types(defined as enum reference to
enum) priorities, preemption , burst time for each of the process structures. -
At the end of the simulation if all process
isFinishedthen exit loop and printturnaround timeandwaiting time.
-
make -
./scheduler -
Test with different input changing to input file as
defX.txt.