

lets get familiar with some terms related to Scheduling Algortihms.īurst Time : indicates the time that a process will take to complete its execution i.e. ("pid arrival burst complete turn waiting") ("enter process " +(i+1)+ " burst time:") ("enter process " +(i+1)+ " arrival time:") Int k= new int // it is also stores brust time Int wt = new int // wt means waiting time

Int ta = new int // ta means turn around time Int pid = new int // it takes pid of process Process id Completion time Waiting time Turnaround time P1 6 1 4 P2 3 0 2 P3 10 3 7 P4 16 5 11Īverage turnaround time = (4+2+7+11)/4 = 6.0Īverage waiting time = (1+0+3+5)/4 = 2.25 Java Program for Shortest Job First (SRTF) Scheduling (Preemptive) When process is added to queue or process is completed then only CPU may switch the process. Process id Arrival time Burst time P1 2 3 P2 1 2 P3 3 4 P4 5 6 In SRTF process will run till completion or a new process added into queue which is having smaller execution time than the current process remaining execution time. But the difference is In SJF process will run till completion. In SRTF the selection of job is same like in SJF. Now we will see preemptive version of SJF that is SRTF (shortest remaining tie first) Preemptive

Execution time should be estimated prior to the scheduling.It will create starvation problem to long process.It will result minimum average waiting time to each process.("\naverage tat is "+ (float)(avgta/n)) ("\npid arrival brust complete turn waiting") * If c=n means c value can not updated because no process arrival time< system time so we increase the system time */ * If i'th process arrival time <= system time and its flag=0 and burst