by Parker Brandt (ID: 113521131)
Running the Program
To run the program, simply type "make all" in the command line and it will compile to an executable file named "project1".
From there, the user can just type "./project1 [filename]" to run the program. [filename] should be replaced with the name of the file with the instructions for the program.
Functions
char* readline(int fd)
This function takes in a file descriptor, and then uses that file descriptor to read the file. The function reads the file until a newline character appears, and once it does, it returns the string before the newline character.
char** split(char* string, char split)
This function takes in a string as the "char* string" parameter splits the string into an array of strings according to the "char split" parameter. The function then returns the array of strings.
int countContextSwitches(Process* processes, int numInstructions)
This function counts the number of voluntary context switches in the list of processes provided as the first parameter. The other parameter, is the number of instructions provided in the input file. The function returns the integer number of voluntary contextswitches.
(NOTE: A voluntary context switch is when a process completes and does not complete later)
int countNonvolSwitches(Process* processes, int numInstructions)
This function counts the number of nonvoluntary context switches in a list of processes provided in the first parameter.
(NOTE: A nonvoluntary context switch is when a process finishes its burst but has not yet completed)
double calcCPUUtilization(Process* processes, int numInstructions)
This function calculates the CPU utilization percentage. In this programming project, the CPU will be utilized 100% of the time, so it should always return 100.00
double calcThroughput(Process* processes, int numThreads, int numInstructions)
This function calculates the average throughput of all of the processes given in the first parameter. The second parameter "int numThreads" is the number of individual threads in the processes list while "int numInstructions" is the number of total instructions and a singular thread can have multiple instructions.
(NOTE: Throughput is the number of executions completed per unit time, and no specific time unit was given in this assignment)
double calcTurnaroundTime(Process* processes, int numThreads, int numInstructions)
Calculates the average turnaround time of all of the processes in the processes list. Turnaround time is the time from submission until completion, so in this assignment the average turnaround time will be the time for each process to complete divided by the number of threads.
double calcWaitingTime(Process* processes, int numThreads, int numInstructions)
This function calculates the average waiting time for each process in "Process* processes" list. The waiting time is the number of time units from submission until the process begins executing.
double calcResponseTime(Process* processes, int numThreads, int numInstructions)
This function calculates the average response time for each process in the processes list. The response time is similar to the wait time, but does not include when the process executes again later.
Assumptions
The main assumption I made is that the number of characters on each line would not exceed 64 characters as I made that the buffer size in my program.