Академический Документы
Профессиональный Документы
Культура Документы
{
int pid; // Process ID
int bt; // Burst Time
int art; // Arrival Time
if (check == false) {
t++;
continue;
}
// Update minimum
minm = rt[shortest];
if (minm == 0)
minm = Integer.MAX_VALUE;
// Increment complete
complete++;
check = false;
if (wt[shortest] < 0)
wt[shortest] = 0;
}
// Increment time
t++;
}
}
// Driver Method
public static void main(String[] args)
{
Process proc[] = { new Process(1, 6, 1),
new Process(2, 8, 1),
new Process(3, 7, 2),
new Process(4, 3, 3)};
findavgTime(proc, proc.length);
}
}
HRRN
import java.util.*;
//______________________________________________________________________
//input
//______________________________________________________________________
System.out.println("Enter # of processes");
int n = sc.nextInt();
int ID;
int TotalWaitingTime = 0;
int TotalTurnAroundTime = 0;
double AVGWaitingTime;
double AVGTurnAroundTime;
System.out.println("_____________________________________");
for (int i = 0; i < n; i++) {
ID = sc.nextInt();
System.out.println("______________________________________");
ArrivalTime[i] = sc.nextInt();
System.out.println("_______________________________________");
ServiceTime[i] = sc.nextInt();
//______________________________________________________________________
//process
//______________________________________________________________________
count = 0;
count++;
min = ServiceTime[i];
j = i;
} else {
if (ServiceTime[i] < min) //checking if the task's service time is less than the current min
min = ServiceTime[i];
StartTime[j] = time;
time += min;
FinishTime[j] = time;
TotalWaitingTime += WaitingTime[y];
TotalTurnAroundTime += TurnAroundTime[y];
//______________________________________________________________________
//output
//______________________________________________________________________
System.out.println("_______________________________________");
System.out.println("____________________________________________________");
System.out.println("_______________________________________");
System.out.println("____________________________________________________");
System.out.println("____________________________________________________");
System.out.println("_______________________________________");
System.out.println("____________________________________________________");
System.out.println("____________________________________________________");
}
RR
import java.util.*;
public class rr
// processes
// burst times.
rem_bt[i] = bt[i];
while(true)
if (rem_bt[i] > 0)
t += quantum;
// by quantum
rem_bt[i] -= quantum;
else
t = t + rem_bt[i];
rem_bt[i] = 0;
if (done == true)
break;
// bt[i] + wt[i]
int quantum)
{
int wt[] = new int[n], tat[] = new int[n];
// around time
(float)total_wt / (float)n);
(float)total_tat / (float)n);
// Driver Method
public static void main(String[] args)
int n = sc.nextInt();
// process id's
//int n = processes.length;
for(int i=0;i<n;i++)
processes[i] = sc.nextInt();
burst_time[i] = sc.nextInt();
// Time quantum
int quantum = 3;