[Solved]Description Homework Asked Implement Multithreaded Program Allow Us Measure Performance Ie Q37248029


Description In this homework, you are asked to implement a multithreaded program that will allow us to measure the performance (ie., CPU utilization, Throughput, Turnaround time, and Waiting time in Ready Queue) of the four basic CPU scheduling algorithms (namely, FIFO, SJE 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 wi 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 [FIFOISJFI PRIRR] [-quantum [integer (ms)1 -input [file name ] The output of your program will be as follows Input File Name CPU Scheduling Alg CPU utilization Throughput Avg. Turnaround time Avg. Waiting time in R queue: : file name FIFO I SJF PRİRR (quantum) : The input file is formatted such that each line starts with proc, sleep, stop keywords. Following proc, there wll 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 thread0) 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 IO 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 inputl.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 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 /O system thread will check IO queue; if there is a process, t 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 free to design and implement this program in C/C++ or Java but if you use Java, DO NOT use the·synchronized> methods or high-level thread-safe Java classes. Instead use some form of semaphore or basic synchronization mechanisms in Java. Also synchronized (obj) structure is OK to use for protecting critical sections in your methods) 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 Show transcribed image text Description In this homework, you are asked to implement a multithreaded program that will allow us to measure the performance (ie., CPU utilization, Throughput, Turnaround time, and Waiting time in Ready Queue) of the four basic CPU scheduling algorithms (namely, FIFO, SJE 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 wi 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 [FIFOISJFI PRIRR] [-quantum [integer (ms)1 -input [file name ] The output of your program will be as follows Input File Name CPU Scheduling Alg CPU utilization Throughput Avg. Turnaround time Avg. Waiting time in R queue: : file name FIFO I SJF PRİRR (quantum) : The input file is formatted such that each line starts with proc, sleep, stop keywords. Following proc, there wll 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 thread0) 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 IO 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 inputl.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 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 /O system thread will check IO queue; if there is a process, t 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 free to design and implement this program in C/C++ or Java but if you use Java, DO NOT use the·synchronized> methods or high-level thread-safe Java classes. Instead use some form of semaphore or basic synchronization mechanisms in Java. Also synchronized (obj) structure is OK to use for protecting critical sections in your methods) 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
Expert Answer
Answer to Description In this homework, you are asked to implement a multithreaded program that will allow us to measure the perfo… . . .
OR

