Priority Scheduling

Priority Scheduling

  • Priority is assigned for each process.
  • Process with highest priority is executed first and so on.
  • Processes with same priority are executed in FCFS manner.
  • Priority can be decided based on memory requirements, time requirements or any other resource requirement.
  • for example:

Priority Scheduling

Contributor's Info

Created:
0Comment
Priority Based Process Scheduling (Preemptive/Non-preemptive)

Priority based (Non-preemptive) Process Scheduling: Priority can be internal or external and static or dynamic. This algorithm selects process with highest priority to execute.

Example: Consider the following table:

Process no.

Arrival Time

Burst Time

Priority

P1

0

6

2

P2

2

1

4 (Lowest)

P3

4

4

1 (Highest)

P4

5

3

3

Find the average waiting time and average turn arround time using Priority(Non-preemptive) algorithm?

Solution: Using Priority(non-preemptive) algorithm, gantt chart is:

23.jpg

 

Therefore,
 

Waiting Time

Turn around Time

Completion Time

Process No.

Arrival Time

Burst Time

Priority

6 - 6 = 0

6 - 0 = 6

6

P1

0

6

2

12 - 1 = 11

14 - 2 = 12

14

P2

2

1

4 (Lowest)

5 - 4 = 1

10 - 5 = 5

10

P3

5

4

1 (highest)

7 - 3 = 4

13 - 6 = 7

13

P4

6

3

3

 

So,
Average Turn arround time  = (6 + 12 + 5 + 7) / (4) = 7.5

Average Waiting time = (0 + 11 + 1 + 4) / (4) = 4

Priority based (preemptive) Process Scheduling: This algorithm selects process with highest priority to execute and it’s preempted lower priority process.

Example: Consider the following table:

Process no.

Arrival Time

Burst Time

Priority

P1

0

6

2

P2

2

1

4 (Lowest)

P3

4

4

1 (Highest)

P4

5

3

3

Find the average waiting time and average turn arround time using Priority(Preemptive) algorithm?

Solution: Using Priority(Preemptive) algorithm, gantt chart is:

 

24.jpg

 

Therefore,
 

Waiting Time

Turn around Time

Completion Time

Process No.

Arrival Time

Burst Time

Priority

10 - 6 = 4

10 - 0 = 10

10

P1

0

6

2

12 - 1 = 11

14 - 2 = 12

14

P2

2

1

4 (Lowest)

4 - 4 = 0

9 - 5 = 4

9

P3

5

4

1 (highest)

7 - 3 = 4

13 - 6 = 7

13

P4

6

3

3

 

So,
Average Turn arround time  = (10 + 12 + 4 + 7) / (4) = 8.25

Average Waiting time = (4 + 11 + 0 + 4) / (4) = 4.75

 

Contributor's Info

Created:
0Comment