-
Notifications
You must be signed in to change notification settings - Fork 0
/
_Grup_17_FCFS.java
47 lines (45 loc) · 1.91 KB
/
_Grup_17_FCFS.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package _Grup_17_package;
public class _Grup_17_FCFS
{
static void waitTime(String processID[], int capacity, int burstTime[], int waitTime[])
{
waitTime[0] = 1;
for (int stage = 1; stage < capacity; stage++)
{
waitTime[stage] = burstTime[stage - 1] + waitTime[stage - 1];
}
}
static void averageWaitingTime(String processID[], int capacity, int burstTime[], int waitTime[], int averageWaitingTime[])
{
for (int stage = 0; stage < capacity; stage++)
{
averageWaitingTime[stage] = burstTime[stage] + waitTime[stage];
}
}
static void FCFS(String processID[], int capacity, int burstTime[]) throws InterruptedException
{
int waitTime[] = new int[capacity], averageWaitingTime[] = new int[capacity];
int totalAverageWaitingTime = 0, totalAverageTime = 0;
waitTime(processID, capacity, burstTime, waitTime);
averageWaitingTime(processID, capacity, burstTime, waitTime, averageWaitingTime);
System.out.println("FCFS Simülasyonu");
for (int stage = 0; stage < capacity; stage++)
{
totalAverageWaitingTime = totalAverageWaitingTime + waitTime[stage];
totalAverageTime = totalAverageTime + averageWaitingTime[stage];
Thread.sleep(1000);
System.out.println(processID[stage] + " prosesi " + waitTime[stage] + ". saniyede kuyruğa girdi.");
Thread.sleep(1000);
System.out.println(processID[stage] + " prosesi " + waitTime[stage] + ". saniyede çalışmaya başladı.");
Thread.sleep(1000);
System.out.println(processID[stage] + " prosesi toplamda " + burstTime[stage] + ". saniyede çalıştı.");
}
System.out.printf("\n");
float averagewaitingTime = (float)totalAverageWaitingTime /(float) capacity;
int averageTurnTime = totalAverageTime / capacity;
Thread.sleep(1000);
System.out.println("Ortalama Bekleme Zamanı: "+ averagewaitingTime);
Thread.sleep(1000);
System.out.println("Ortlama Çalışma Zamanı: "+ averageTurnTime);
}
}