The text files should be hyperlinked into the document as well.
CS 3733 Operating Systems: Assignment 5 - new Write all your programs under assign5. You need to implement this assignment using C with pthread library!!! (no Java) Objective · Learn and practice CPU scheduling algorithms by implementing them · Learn and practice process/thread synchronization mechanisms by implementing them · Practice system calls and library functions Description In this homework, you are asked to implement a multithreaded program that will allow us to measure the performance (i.e., CPU utilization, Throughput, Turnaround time, and Waiting time in Ready Queue) of the four basic CPU scheduling algorithms (namely, FIFO, SJF, PR, and RR). Your program will be emulating/simulating the processes whose priority, sequence of CPU burst time(ms) and I/O burst time(ms) will be given in an input file. Assume that all scheduling algorithms except RR will be non-preemptive, and all scheduling algorithms except PR will ignore process priorities (i.e., all processes have the same priority in FIFO, SJF and RR). Also assume that there is only one IO device and all IO requests will be served using that device in a FIFO manner. -------------------------------------------------------------------------------------------------------------------------- Your program will take the name of the scheduling algorithm, related parameters (if any), and an input file name from command line. Here how your program should be executed: prog -alg [FIFO|SJF|PR|RR] [-quantum [integer(ms)]] -input [file name] The output of your program will be as follows: Input File Name : file name CPU Scheduling Alg : FIFO|SJF|PR|RR (quantum) CPU utilization : .... Throughput : .... Avg. Turnaround time : .... Avg. Waiting time in R queue : .... -------------------------------------------------------------------------------------------------------------------------- The input file is formatted such that each line starts with proc, sleep, stop keywords. Following proc, there will be a sequence of integer numbers: the first one represents the priority (1: lowest, ..., 5: normal, ..., 10: highest). The second number shows the number of remaning integers representing CPU burst and I/O burst times (ms) in an alternating manner. The last number will be the last CPU burst time after which that process exits. Following sleep, there will be an integer number representing the time (ms) after which there will be another process. So one of the threads in your program (e.g., FileRead_thread()) would be responsible for processing this file as follows. As long as it reads proc, it will create a new process and put it in a ready queue (clearly this process is not an actual one, it will be just a simple data structure (similar to PCB) that contains the given priority and the sequence of CPU burst and I/O burst times, and other fields). When this thread reads sleep x, it will sleep x ms and then try to read new processes from the file. Upon reading stop, this thread will quit. -------------------------------------------------------------------------------------------------------------------------- Here is a sample input file (copy/paste this to create an input1.txt you can create other similar files too): --------------------------------------------------------------------------------------------------------------------------- proc 1 7 10 20 10 50 20 40 10 proc 1 5 50 10 30 20 40 sleep 50 proc 2 3 20 50 20 proc 3 3 20 50 20 sleep 50 proc 2 3 20 50 20 stop -------------------------------------------------------------------------------------------------------------------------- In this program you need at least three threads: As described above, one thread (say FileRead_thread) will read the above file, create a process (not a real process just a data structure representing the characteristic of the process that will be emulated/simulated), and puts it in a ready queue. CPU scheduler thread will check ready queue; if there is a process, it will pick one according to the scheduling algorithm from ready queue and hold CPU resource for the given CPU burst time (or for quantum time if the scheduling algorithm is RR). That means CPU thread will simply sleep for the given CPU burst time to emulate/simulate the process. Then it will release CPU resource and put this process into IO queue (or ready queue if RR is used) or just terminate if this is the last CPU burst. Then CPU scheduler thread will check ready queue again and repeat the same for the next process. I/O system thread will check IO queue; if there is a process, it will sleep for the given IO burst time to emulate/simulate the usage of IO device. It then puts this process back into ready queue. Finally it will check IO queue and repeat the same .... --------------------------------------------------------------------------------------------------------------------------- Basically you will have at least the above mentioned three threads and the main one. These threads need to be synchronized as they cooperate to collect data for performance measures and share data through ready and IO queues. Main thread will wait until the file reading thread is done and the ready queue and IO queue are empty, then it will print the performance evaluation results and terminate the program... You are asked to design and implement this program in C using pthread (no Java) Also you can use any data structures in different parts of your program and share them along with new variables; but when it comes to maintaining the list of processes in ready queue or IO queue, we would like you to use double linked list, as this is the case in many practical OS. If you still need extra help, click here to download pdf file and watch tk-assign-05-help-29min --------------------------------------------------------------------------------------------------------------------------- Test Case: Please check your program with input2.txt You can then compare your outputs with the ones provided in output2.txt As I mentioned you might be getting slightly different numbers even when you run the same program again! That is fine! --------------------------------------------------------------------------------------------------------------------------- Grading: This is a 60-point homework. First make sure your program works for FIFO CPU scheduling. This will be 25 points. Then you can add/test the others: SJF (10 points), PR (10 points) and RR (10 points). Write a 2-3 page report (5 points) to describe your design choices at the high level and your results. Do all your work under a directory assign5, which should include your source codes, instructions to compile/execute, and some output files showing your test results etc... ---------------------------------------------------------------------------------------------------------------------------