0% found this document useful (0 votes)
2 views

Process Scheduling Algorithms

Uploaded by

thejasnaikrh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Process Scheduling Algorithms

Uploaded by

thejasnaikrh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Process Scheduling Algorithms

The question is about process scheduling algorithms. We are given four processes (P1, P2, P3, P4)

with their arrival times (A.T), burst times (B.T), and priorities (Pn).

We need to determine the scheduling order using three different algorithms: First-Come,

First-Served (FCFS), Shortest Remaining Time First (SRTF), and Preemptive Priority.

Assume smaller priority numbers indicate higher priority.

Step 1: FCFS Scheduling

FCFS schedules processes in the order they arrive.

| Process | A.T | B.T | Completion Time | Turnaround Time | Waiting Time |

|---|---|---|---|---|---|

| P1 | 0 | 7 | 7 | 7 | 0 |

| P2 | 3 | 5 | 12 | 9 | 4 |

| P3 | 3 | 3 | 15 | 12 | 9 |

| P4 | 5 | 5 | 20 | 15 | 10 |

Average waiting time = (0 + 4 + 9 + 10) / 4 = 5.75

Step 2: SRTF Scheduling

SRTF schedules the process with the shortest remaining burst time. It's preemptive.

| Time | Process | Remaining Time |


|---|---|---|

| 0-7 | P1 | 7 -> 0 |

| 7-10 | P2 | 5 -> 2 |

| 10-12 | P3 | 3 -> 0 |

| 12-15 | P2 | 2 -> 0 |

| 15-20 | P4 | 5 -> 0 |

| Process | A.T | B.T | Completion Time | Turnaround Time | Waiting Time |

|---|---|---|---|---|---|

| P1 | 0 | 7 | 7 | 7 | 0 |

| P2 | 3 | 5 | 12 | 9 | 4 |

| P3 | 3 | 3 | 12 | 9 | 6 |

| P4 | 5 | 5 | 20 | 15 | 10 |

Average waiting time = (0 + 4 + 6 + 10) / 4 = 5

Step 3: Preemptive Priority Scheduling

This algorithm schedules the process with the highest priority (lowest Pn value). It's preemptive.

We'll use a Gantt chart to visualize.

| Time | Process | Priority |

|---|---|---|

| 0-3 | P1 | 1 |

| 3-6 | P2 | 2 |

| 6-9 | P3 | 3 |

| 9-14 | P4 | 4 |
| 14-17 | P1 | 1 |

| 17-20 | P4 | 4 |

| Process | A.T | B.T | Completion Time | Turnaround Time | Waiting Time |

|---|---|---|---|---|---|

| P1 | 0 | 7 | 17 | 17 | 10 |

| P2 | 3 | 5 | 6 | 3 | 0 |

| P3 | 3 | 3 | 9 | 6 | 3 |

| P4 | 5 | 5 | 20 | 15 | 10 |

Average waiting time = (10 + 0 + 3 + 10) / 4 = 5.75

Final Answer

FCFS: Average waiting time = 5.75

SRTF: Average waiting time = 5

Preemptive Priority: Average waiting time = 5.75

You might also like