Operating System Long Questions and AnswersHere in this section of Operating System Long Questions and Answers,We have listed out some of the important Long Questions with Answers on Preemptive Priority Scheduling algorithms which will help students to answer it correctly in their University Written Exam.

Lists of Long Descriptive type Questions that may be asked in Written Exams.

  • (1) Explain Preemptive Priority Scheduling algorithms.

Question-1  Explain Preemptive Priority Scheduling algorithms with illustration.

Selection criteria:

The process, that has highest priority, is served first.

Decision Mode:

Preemptive: When a new process arrives, its priority is compared with current process priority. If the new job has higher priority than the current, the current process is suspended and new job is started.

Implementation:

This strategy can be implemented by using sorted FIFO queue. All processes in a queue are sorted based on priority with highest priority process at front end. When CPU becomes free, a process from the first position in a queue is selected to run.

Example:

Consider the following set of four processes. Their arrival time, time required completing the execution and priorities are given in following table. Consider all time values in milliseconds and small value of priority means higher priority of the process.

ProcessArrival Time (T0)Time required for completion (∆T)Priority
P00105
P1164
P2322
P3540

Here process priorities are in this order: P3>P2>P1>P0

Gantt chart:

P0P1P2P3P1P0
013591322

Initially only process P0 is present and it is allowed to run. But when P1 comes, it has higher priority. So, P0 is preempted and P1 is allowed to run. This process is repeated till all processes complete their execution.

Statistics:

ProcessArrival Time (T0)Completion Time (∆T)Finish Time(T1)Turnaround Time (TAT=T1-T0)Waiting Time (TAT-∆T)
P0010222212
P11613126
P232520
P354940

 Average Turnaround Time: (22+12+2+4) / 4 = 40 / 4 = 10 ms

Average Waiting Time: (12+6+0+0) / 4 = 18 / 4 = 4.5 ms

Advantages:

  • Priority is considered. Critical processes can get even better response time.

Disadvantages:

  • Starvation is possible for low priority processes. It can be overcome by using technique called ‘Aging’.
  • Aging: gradually increases the priority of processes that wait in the system for a long time.
  • Context switch overhead is there.
Share with :