Priority Scheduling

1. PRIORITY SCHEDULING ALGORITHM:

AIM:

To write a c program to simulate the CPU scheduling priority algorithm.

DESCRIPTION:

To calculate the average waiting time in the priority algorithm, sort the burst times according to their priorities and then calculate the average waiting time of the processes. The waiting time of each process is obtained by summing up the burst times of all the previous processes.

ALGORITHM:

  1. Start the process
  2. Accept the number of processes in the ready Queue
  3. For each process in the ready Q, assign the process id and accept the CPU burst time
  4. Sort the ready queue according to the priority number.
  5. Set the waiting of the first process as ‗0‘ and its burst time as its turnaround time
  6. Arrange the processes based on process priority
  7. For each process in the Ready Q calculate Waiting time(n)= waiting time (n-1) + Burst time (n-1)
  8. For each process in the Ready Q calculate Turnaround time (n)= waiting time(n)+Burst time(n)
  9. Calculate Average waiting time = Total waiting Time / Number of process and Average Turnaround time = Total Turnaround Time / Number of process. Print the results in an order.
  10. Stop