Reference no: EM131578
Program to be implemented in C++ language - Operating System and CPU Scheduling and Linux Schedulers
Purpose:
The purpose of this project is to provide insight into the Linux Process Scheduling Algorithm by simulating a simplified version of the CPU scheduler.
Background:
The Linux Process Scheduler divides CPU time into epochs. In a single epoch, every process has a specified time slice. In a single epoch, the CPU's job is to schedule contending processes to use the CPU in a fair and efficient manner.
Time slice, priority, nice value and bonus:
The Linux Process Scheduler uses time slice to prevent a single process from using the CPU for too long. A time slice specifies how long the process can use the CPU. In our simulation, the minimum time slice possible is 10ms and the maximum time slice possible is 300 ms. The scheduler assigns higher time slices to processes that are more interactive and lower time slices to processes that are more CPU intensive. Note that time slice is a positive integer in this range [10, 300]. To calculate the time slice, we use this formula:
Each process is supplied with a priority level that ranks a process based on their worth and need for processor time. The priority levels range from 100 to 140 [100,140]. Processes with a lower priority will run before a process with a higher priority. Process with a lower priority level also receives a longer time slice. A process's initial priority (sometimes called static priority) is calculated based on its nice value. Nice values range from -20 to +19 [-20, 19] indicating how nice the process is. Larger nice values correspond to a lower priority. CPU intensive processes typically have higher nice values while IO bound processes have lower nice values. Nice values are provided with the input file. Note that a priority value is a positive integer in this range [100,140]. To calculate the initial (or static) priority we use this formula:
After a process exhausts its time slice, it will join the expired queue or go back to the active queue. Before doing that, it has to calculate its new priority (sometimes called the dynamic priority). This is the formula used to calculate the dynamic priority:
priority = original priority + bonus:
Bonus points are given to processes that either use too much or too little CPU time. Bonus points are integers range from -5 to +5 ([-5, 5]). Here are the guidelines to calculating bonus points:
Note : Here total IO mean the total time spent in the IO queue to this point and total CPU mean the total time spent in the CPU to this point.
Run queues/Priority Array:
The runqueue is the list of runnable processes on a given processor. There is only one runqueue per processor. Each runqueue contains two priority arrays: Active and Expired. Each priority array contains one queue of runnable processes per priority level. Each array has 140 levels, thus 140 queues. A process with priority level 125 will go to the _125th _ queue. In this project, we will not implement all 140 queues. We will only implement a single queue. In the real Linux scheduler, each queue represents one priority level. In our project, we will have a single data structure. The active array contains processes that have yet to exhaust their time slice. Once their time slice is exhausted, it will go to the expired array. There is also an IO queue. This queue is used to hold processes that are using IO. There will be no waiting for access to IO devices.
Thus, all the processes in the IO queue can decrease their IO burst in each clock tick.