CPU SCHEDULING MAY BE CLASSIFIED AS:
1. NON-PREEMPTIVE SCHEDULING
In Non-Preemptive Scheduling, the CPU cannot be taken away from its currently executing process. The only time the CPU scheduler can assign the CPU to another process in the ready queue is when the currently executing process terminates or enters into a Blocked state.
2. PREEMPTIVE SCHEDULING
In Preemptive Scheduling, the CPU can be taken away from its currently executing process. The currently executing process is sent back to the ready queue and the CPU scheduler assigns the CPU to another process. This will happen if:
a. An interrupt occurred so the current process has to stop executing. The CPU is then assigned to execute the ISR of the requesting device or process.
b. The priority of the process that enters the ready queue is higher than the currently executing process. The CPU is then assigned to execute the higher-priority process.
c. The time limit of a process for using the CPU has been exceeded. The CPU is then assigned to execute another process even though running process has not yet completed its current CPU burst.
Preemptive scheduling is ideally used for interactive or real-time computing systems. Non-preemptive scheduling is good for batch processing systems only. However, non-preemptive scheduling has fewer context switches than preemptive scheduling; therefore the former has less overhead.
CPU SCHEDULING ALGORITHMS PERFORMANCE CRITERIA
The following performance criteria should be optimized by a good scheduler:
1. CPU UTILIZATION
The CPU must be busy doing useful work at all times.
The amount of work done by the CPU should be maximized.
3. TURNAROUND TIME – the time between the point a process is submitted and the time it finishes executing is minimized.
4. RESPONSE TIME – the time between the submission of a request and the start of the systems first response is minimized.
5. WAITING TIME – the time a process has to spend inside the ready queue waiting to be executed by the CPU is minimized. Many considers this as a measure of how good a scheduling algorithm is since waiting time somehow have an impact on the order of process execution.
Note that a scheduling algorithm cannot optimize all the performance criteria because of conflicts. Some criteria might be optimized while others are compromised. The scheduling algorithm may select to optimize only one or two criteria, which depends on the type of computer system being used.
FAIRNESS, meaning all processes will be given equal opportunity to use the CPU, is another performance criterion. It is hard to measure so it was not included in the above list.
DIFFERENT CPU SCHEDULING ALGORITHMS
1. FIRST-COME, FIRST-SERVED ALGORITHM (FCFS)
It is a non-preemptive scheduling algorithm wherein the one that enters the Ready queue first gets to be executed by the CPU first. In choosing the next process to be executed, the CPU scheduler selects the process at the front of the Ready queue. Processes enter at the rear of the Ready queue.
A set of processes with their respective arrival times at the Ready queue and the length of their next CPU burst are given below.
|Process ID |Arrival Time |CPU Burst | |A |0 |8 | |B |3 |4 | |C |4 |5 | |D |6 |3 | |E |10 |2 |
All values are in milliseconds.
In the succeeding solutions, Gantt charts are used to illustrate the time each process starts and ends executing.
Please join StudyMode to read the full document