-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhrrn.cpp
More file actions
112 lines (103 loc) · 2.74 KB
/
hrrn.cpp
File metadata and controls
112 lines (103 loc) · 2.74 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// #include <iostream>
// #include <algorithm>
// using namespace std;
// struct node
// {
// char pname[50];
// int btime;
// int atime;
// int wtime;
// float rr = 0;
// } a[50];
// void insert(int n)
// {
// int i;
// for (i = 0; i < n; i++)
// {
// cin >> a[i].pname;
// cin >> a[i].atime;
// cin >> a[i].btime;
// a[i].rr = 0;
// a[i].wtime = -a[i].atime;
// }
// }
// bool btimeSort(node a, node b)
// {
// return a.btime < b.btime;
// }
// bool atimeSort(node a, node b)
// {
// return a.atime < b.atime;
// }
// bool rrtimeSort(node a, node b)
// {
// return a.rr > b.rr;
// }
// void disp(int n)
// {
// sort(a, a + n, btimeSort);
// sort(a, a + n, atimeSort);
// int ttime = 0, i;
// int j, tArray[n];
// for (i = 0; i < n; i++)
// {
// j = i;
// while (a[j].atime <= ttime && j != n)
// {
// j++;
// }
// for (int q = i; q < j; q++)
// {
// a[q].wtime = ttime - a[q].atime;
// a[q].rr = (float)(a[q].wtime + a[q].btime) / (float)a[q].btime;
// }
// sort(a + i, a + j, rrtimeSort);
// tArray[i] = ttime;
// cout << endl;
// ttime += a[i].btime;
// }
// tArray[i] = ttime;
// float averageWaitingTime = 0;
// float averageResponseTime = 0;
// float averageTAT = 0;
// cout << "\n";
// cout << "P.Name AT\tBT\tCT\tTAT\tWT\tRT\n";
// for (i = 0; i < n; i++)
// {
// cout << 'P' << a[i].pname << "\t";
// cout << a[i].atime << "\t";
// cout << a[i].btime << "\t";
// cout << tArray[i + 1] << "\t";
// cout << tArray[i] - a[i].atime + a[i].btime << "\t";
// averageTAT += tArray[i] - a[i].atime + a[i].btime;
// cout << a[i].wtime << "\t";
// averageWaitingTime += tArray[i] - a[i].atime;
// cout << tArray[i] - a[i].atime << "\t";
// averageResponseTime += tArray[i] - a[i].atime;
// cout << "\n";
// }
// cout << "\n";
// cout << "\nGantt Chart\n";
// for (i = 0; i < n; i++)
// {
// cout << "| P" << a[i].pname << " ";
// }
// cout << "\n";
// for (i = 0; i < n + 1; i++)
// {
// cout << tArray[i] << "\t";
// }
// cout << "\n";
// cout << "Average Response time: " << (float)averageResponseTime / (float)n << endl;
// cout << "Average Waiting time: " << (float)averageWaitingTime / (float)n << endl;
// cout << "Average TA time: " << (float)averageTAT / (float)n << endl;
// }
// int main()
// {
// int nop, choice, i;
// cout << "Enter number of processes\n";
// cin >> nop;
// insert(nop);
// disp(nop);
// return 0;
// }