ProcessArrival TimeBurst TimePriority
P1084
P2143
P3291
P4352

1. First-Come, First-Served (FCFS)

Description:

In FCFS, processes are scheduled in the order they arrive in the ready queue. It is a non-preemptive algorithm, meaning once a process starts execution, it runs to completion without being interrupted.

Gantt Chart:

| P1 | P2 | P3 | P4 |
0    8   12   21   26

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P188 - 0 = 88 - 8 = 0
P21212 - 1 = 1111 - 4 = 7
P32121 - 2 = 1919 - 9 = 10
P42626 - 3 = 2323 - 5 = 18

Average Turnaround Time = 15.25

Average Waiting Time = 8.75


2. Shortest Job First (SJF)

Description:

In SJF, the process with the smallest burst time is selected for execution next. This can be either preemptive or non-preemptive. In non-preemptive SJF, a running process cannot be interrupted; in preemptive SJF, a process can be interrupted if a new process with a shorter burst time arrives.

Gantt Chart:

| P2 | P4 | P1 | P3 |
0    4   9    17   26

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P11717 - 0 = 1717 - 8 = 9
P244 - 1 = 33 - 4 = -1
P32626 - 2 = 2424 - 9 = 15
P499 - 3 = 66 - 5 = 1

Average Turnaround Time = 12.5

Average Waiting Time = 6.25


3. Shortest Remaining Time Next (SRTN)

Description:

SRTN is a preemptive version of SJF. It allows a currently running process to be interrupted if a new process arrives with a shorter remaining time. The CPU is allocated to the process with the shortest remaining time.

Gantt Chart:

| P1 | P2 | P1 | P4 | P3 |
0    1   5    8    13   26

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P188 - 0 = 88 - 8 = 0
P255 - 1 = 44 - 4 = 0
P32626 - 2 = 2424 - 9 = 15
P41313 - 3 = 1010 - 5 = 5

Average Turnaround Time = 11.5

Average Waiting Time = 5


4. Priority-Based Preemptive Scheduling (PBPS)

Description:

In PBPS, each process is assigned a priority, and the CPU is allocated to the process with the highest priority (lower numbers indicate higher priority). This scheduling can preempt a currently running process if a new process with a higher priority arrives.

Gantt Chart:

| P3 | P4 | P2 | P1 |
0    2   7    11   26

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P12626 - 0 = 2626 - 8 = 18
P21111 - 1 = 1010 - 4 = 6
P322 - 2 = 00 - 9 = -9
P477 - 3 = 44 - 5 = -1

Average Turnaround Time = 10

Average Waiting Time = 3.5


5. Time Slice Scheduling (Assuming a Time Slice of 2)

Description:

In this algorithm, each process is assigned a fixed time slice (quantum). If a process does not complete its execution within the time slice, it is moved to the back of the ready queue. This approach is designed to ensure all processes receive a fair share of CPU time.

Gantt Chart:

| P1 | P2 | P3 | P4 | P1 | P3 |
0    2   4   6   8   10  21

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P12121 - 0 = 2121 - 8 = 13
P21212 - 1 = 1111 - 4 = 7
P32626 - 2 = 2424 - 9 = 15
P41414 - 3 = 1111 - 5 = 6

Average Turnaround Time = 16.75

Average Waiting Time = 10.25


6. Round Robin (RR)

Description:

Round Robin is a preemptive scheduling algorithm that assigns a fixed time slice to each process in the ready queue. Each process runs for its allotted time slice before the CPU is given to the next process. This method helps to ensure that all processes receive equal attention and minimizes response time for interactive systems.

Gantt Chart:

| P1 | P2 | P3 | P4 | P1 | P3 |
0    2   4   6   8   10  21

Completion, Turnaround, and Waiting Times:

ProcessCompletion TimeTurnaround TimeWaiting Time
P11010 - 0 = 1010 - 8 = 2
P21212 - 1 = 1111 - 4 = 7
P32121 - 2 = 1919 - 9 = 10
P41414 - 3 = 1111 - 5 = 6

Average Turnaround Time = 12.25

Average Waiting Time = 6.25


Summary of Results

AlgorithmAverage Turnaround TimeAverage Waiting Time
FCFS15.258.75
SJF12.56.25
SRTN11.55
PBPS103.5
Time Slice Scheduling16.7510.25
Round Robin12.256.25

This overview provides a comprehensive understanding of each scheduling algorithm, their mechanisms, and the performance metrics for the specified processes. If you have any further questions or need additional details, feel free to ask!