-
Notifications
You must be signed in to change notification settings - Fork 0
/
NONAME00.CPP
100 lines (74 loc) · 1.82 KB
/
NONAME00.CPP
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
//SJF.CPP
#include <iostream.h>
#include <string.h>
void main(){
int numberOfProcesses;
String Pstring = "P";
cout<<"Enter the number of processes you want to create";
cin>>numberOfProcesses;
int * BufferTimeUser = new int [numberOfProcesses];
for( int i = 0 ; i < numberOfProcesses; i++){
string ProcessesID;
int timing;
cin>>timing;
itoa( i , ProcessesID ,10);
strncat(Pstring,ProcessesID , Pstring.length()+ProcessesID.length());
Processes[i] = new process(ProcessesID, timing);
}
}
class process{
string processID;
int BurstTiming;
string SequenceTiming;
int EstimatedTime;
int waitingTime;
int TurnAroundTime;
public:
process(string ID, int Timing){
this.processID = ID;
this.timing = Timing;
}
/*
There is just one constructor
*/
process(){
//Default constructor
}
void setET(process *array , int length){
int min;
array[0].timing=min;
for( int i = 0 ; i < length ; i++){
array[i].timing=min;
for(int j = i ; j < length ; j++){
if(array[j].timing<min){
min=array[j];
}
}
array[i].EstimatedTime = min;
}
}
void setSequenceOfExecution(process * Array , int length ){
for(int i = 0; i < length; i++){
int temp;
for(int j = 0 ; j < length ; i++){
if(Array[i].EstimatedTime==Array[j].BurstTiming){
temp = j;
break;
}
Array[i].sequenceTiming = Array[temp].ProcessID;
}
}
}
void calculateWaitingTime(process * Array, int length){
int start = 0 ;
Array[0].waitingTime=0;
for( int i =1; i < length; i++){
Array[i].waitingTime = Array[i-1].waitingTime+Array[i-1].BurstTime;
}
}
void setTurnAroundTime(process * Array , int length){
for(int i = 0 ; i < length ; i++){
Array[i].TurnAroundTime = Array[i].BurstTime+Array[i].WaitingTime;
}
}
};