Question
ShortestRemainingSort(batchFileData) Parameters: accepts all of the batchFileData from the batchfile opened in main Returns: (1) a list (or other data structure) of the time each
ShortestRemainingSort(batchFileData) Parameters: accepts all of the batchFileData from the batchfile opened in main Returns: (1) a list (or other data structure) of the time each process is completed at, and (2) a list (or other data structure) containing the PID of the processes in the order the algorithm sorted them by. If the command line argument states that the user wants to process batch jobs using ShortestRemaining, then this function will be called. The data from the batchfile should be passed in and sorted by arrival time (again, there are many ways to do this). For this version of shortest remaining, as processes arrive, they are added to the queue. If the burst time of the newest process in the queue is less than the remaining time to execute the current process, the current process should be added back to the queue and the new process should be executed. So in the batchfile above, process 1 and 3 arrive at the same time, but process 1 has a burst time of 20 seconds, so we run process 1. At time = 9, process 7 enters the queue. Process 1 has 11 seconds of execution remaining. Process 7 has a burst time of 4. Therefore, we will pause process 1, save its new burst time (which is the remaining time), and execute process 7. At time 10, process 2 enters the queue. The current process, PID 7, has 3 seconds remaining until full execution, while process 2 needs 12 seconds to fully execute. Therefore, we continue to execute PID 7 until it completes, and check the queue for the process with the shortest remaining burst time- in this case, we would run PID 1 until it is fully executed, then PID 2, then PID 3. This would complete the batch file's process scheduling algorithm. The basic algorithm can be summarized as: At each time (think for loop) Check what processes have arrived in the queue. Compare the arrived process' burst time to the time that remains for the current process to fully execute. If the newest process has a shorter burst time than the remaining time on the current process, update the burst time for the current process to be the remaining time. Then execute the new process with the shorter burst time. Otherwise, continue executing the current process and decrement its remaining time. If two processes arrive at the same time and have the same burst time, execute the process with the smaller PID first The simplest way to check "at each time" is to sort all of the processes by arrival time, but there are a multitude of ways to simulate ShortestRemaining. There are many different ways to update your process queue from the batch file. You can swap items in the batchFileData list. You can construct a dictionary object that tracks each process and the remaining burst time. You can simply update the burst time of a process each time you would have to pause the process. Finally, print the PID values of the processes in the order that they will be executed by the algorithm, the average process waiting time, and average process turn around time.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started