Priority Scheduling.
Priority Scheduling.
The processes with higher priority should be carried out first, whereas jobs
with equal priorities are carried out on a round-robin or FCFS basis. Priority
depends upon memory requirements, time requirements, etc.
Preemptive Scheduling
In Preemptive Scheduling, the tasks are mostly assigned with their priorities.
Sometimes it is important to run a task with a higher priority before another
lower priority task, even if the lower priority task is still running. The lower
priority task holds for some time and resumes when the higher priority task
finishes its execution.
Non-Preemptive Scheduling
In this type of scheduling method, the CPU has been allocated to a specific
process. The process that keeps the CPU busy, will release the CPU either by
switching context or terminating. It is the only method that can be used for
various hardware platforms. That’s because it doesn’t need special hardware
(for example, a timer) like preemptive scheduling.
Step 2) At time 2, no new process arrives, so you can continue with P1. P2 is
in the waiting queue.
Step 3) At time 3, no new process arrives so you can continue with P1. P2
process still in the waiting queue.
Step 4) At time 4, P1 has finished its execution. P2 starts execution.
Step 14) At time =14, the P2 process has finished its execution. P4 and P5 are
in the waiting state. P5 has the highest priority and starts execution.
Step 15) At time =15, P5 continues execution.
Step 16) At time= 16, P5 is finished with its execution. P4 is the only process
left. It starts execution.
Step 17) At time =20, P5 has completed execution and no process is left.
Step 18) Let’s calculate the average waiting time for the above example.
Waiting Time = start time – arrival time + wait time for next burst
P1 = o - o = o
P2 =4 - o + 7 =11
P3= 6-6=0
P4= 16-11=5
Average Waiting time = (0+11+0+5+2)/5 = 18/5= 3.6
• If the system eventually crashes, all low priority processes get lost.
• If high priority processes take lots of CPU time, then the lower priority
processes may starve and will be postponed for an indefinite time.
• This scheduling algorithm may leave some low priority processes
waiting indefinitely.
• A process will be blocked when it is ready to run but has to wait for the
CPU because some other process is running currently.
• If a new higher priority process keeps on coming in the ready queue,
then the process which is in the waiting state may need to wait for a
long duration of time.
Summary