Format code with prettier (#3375)

This commit is contained in:
acbin
2022-10-03 17:23:00 +08:00
committed by GitHub
parent 32b9b11ed5
commit e96f567bfc
464 changed files with 11483 additions and 6189 deletions

View File

@ -53,7 +53,9 @@ class Schedule {
System.out.print("Enter the no. of processes: ");
noOfProcess = in.nextInt();
System.out.println("Enter the arrival, burst and priority of processes");
System.out.println(
"Enter the arrival, burst and priority of processes"
);
for (int i = 0; i < noOfProcess; i++) {
Process p = new Process();
p.pid = i;
@ -75,14 +77,14 @@ class Schedule {
}
void startScheduling() {
processes.sort(
new Comparator<Process>() {
@Override
public int compare(Process a, Process b) {
return a.arrivalTime - b.arrivalTime;
new Comparator<Process>() {
@Override
public int compare(Process a, Process b) {
return a.arrivalTime - b.arrivalTime;
}
}
});
);
while (!(arrivals.size() == 0 && remainingProcess.size() == 0)) {
removeFinishedProcess();
@ -92,19 +94,23 @@ class Schedule {
}
remainingProcess.sort(
new Comparator<Process>() {
private int alpha = 6;
private int beta = 1;
new Comparator<Process>() {
private int alpha = 6;
private int beta = 1;
@Override
public int compare(Process a, Process b) {
int aRem = a.remainingTime;
int bRem = b.remainingTime;
int aprior = a.priority;
int bprior = b.priority;
return (alpha * aRem + beta * aprior) - (alpha * bRem + beta * bprior);
@Override
public int compare(Process a, Process b) {
int aRem = a.remainingTime;
int bRem = b.remainingTime;
int aprior = a.priority;
int bprior = b.priority;
return (
(alpha * aRem + beta * aprior) -
(alpha * bRem + beta * bprior)
);
}
}
});
);
int k = timeElapsed(timer);
ageing(k);
@ -124,7 +130,8 @@ class Schedule {
for (int i = 0; i < completed.size(); i++) {
int pid = remainingProcess.get(completed.get(i)).pid;
processes.get(pid).waitTime = remainingProcess.get(completed.get(i)).waitTime;
processes.get(pid).waitTime =
remainingProcess.get(completed.get(i)).waitTime;
remainingProcess.remove(remainingProcess.get(completed.get(i)));
}
}
@ -158,21 +165,25 @@ class Schedule {
float tatTime = 0;
for (int i = 0; i < noOfProcess; i++) {
processes.get(i).turnAroundTime = processes.get(i).waitTime + processes.get(i).burstTime;
processes.get(i).turnAroundTime =
processes.get(i).waitTime + processes.get(i).burstTime;
waitTimeTot += processes.get(i).waitTime;
tatTime += processes.get(i).turnAroundTime;
System.out.println(
"Process no.: "
+ i
+ " Wait time: "
+ processes.get(i).waitTime
+ " Turn Around Time: "
+ processes.get(i).turnAroundTime);
"Process no.: " +
i +
" Wait time: " +
processes.get(i).waitTime +
" Turn Around Time: " +
processes.get(i).turnAroundTime
);
}
System.out.println("Average Waiting Time: " + waitTimeTot / noOfProcess);
System.out.println(
"Average Waiting Time: " + waitTimeTot / noOfProcess
);
System.out.println("Average TAT Time: " + tatTime / noOfProcess);
System.out.println("Throughput: " + (float) noOfProcess / (timer - 1));
}