Week 2 - Processes and Scheduling
My biggest takeaways from this week’s material has to be in regards to CPU virtualization through limited direct execution and CPU scheduling.
Limited direct execution is a mechanism of multiprogramming as it provides the illusion of running multiple programs at the same time. An example of this is how an OS itself is a process that is part of the constant swapping of processes in multiprogramming. In order for the OS to handle the different processes while also being a process itself there needs to be some balance between how the other processes get access to the CPU while the OS stays in charge. The method I learned in order to achieve this is by allowing limited direct execution. The direct execution is how the process code is run on the CPU while the "limited" part is how the OS sets up the control and protection to prevent the process from performing unauthorized operations. The OS can do this by allowing the process to be created, switch to user mode to execute, handle restricted access with system calls, then system interrupts to gain control again. The two modes to consider are user mode and kernel mode, user limits the access to hardware operations, while kernel mode allows full access. Some other things to note is what if a process needs OS help for I/O, this is where the trap handler comes into play. The process takes place where the CPU switches to kernel mode then jumps to a created trap handler in the OS, and after the OS finishes, return-from-trap switches back to user mode and resumes execution. Other things to consider with limited direct execution is context switching which is saving the state of the process e.g its instructions in registers, and program counter or stack pointer. The OS itself can manage these through interrupts.
The other things I learned this week was how to calculate the metrics of different scheduling algorithms such as FIFO first in first out, SJF shortest job first, STCF shortest time to completion first, and RR round robin. The metrics include the turnaround time which is the time where a job/process completes minus its arrival time and the response time which is the time of its first run minus its arrival time. Each algorithm has its benefits and drawbacks such as the FIFO where jobs of different lengths can lead to poor performance, and in SJF where it is optimal if jobs arrive together. After conducting the lab for scheduling I have found calculating the round robin metrics quite tedious as it involves finding where each job’s completion is using time slices. Overall this week has been quite odd because of the holidays and my personal scheduling. Last thing to note is I definitely need to keep practicing these metric calculations just in case they are in exam 1.
Comments
Post a Comment