-
Notifications
You must be signed in to change notification settings - Fork 0
/
sjf.c
63 lines (56 loc) · 1.38 KB
/
sjf.c
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
#include<stdio.h>
int main(){
int n, bt[20],p[20], wt[20], tat[20], avwt = 0, i,j;
int total, pos, temp;
float avg_tat = 0, avg_wt = 0;
printf("Enter total number of processes: ");
scanf("%d",&n);
printf("\nEnter burst times\n");
for(i = 0; i<n; i++){
printf("p[%d] = ",i+1);
scanf("%d", &bt[i]);
p[i] = i+1;
}
for(i = 0; i < n; i++){
pos = i;
for(j = i+1; j < n; j++){
if( bt[j] < bt [pos])
pos = j;
}
temp = bt[i];
bt[i] = bt[pos];
bt[pos] = temp;
temp = p[i];
p[i] = p[pos];
p[pos] = temp;
}
wt[0] = 0;
for(i = 0; i < n; i++){
wt[i] = 0;
for(j = 0; j < i; j++)
wt[i] += bt[j];
total += wt[i];
}
avg_wt = (float) total / n;
total = 0;
printf("\nProcess Burst Time\tWaiting time\tTurn aroumd time");
for(i =0; i < n; i++){
tat[i] = bt[i] + wt[i];
total += tat[i];
printf("\np%d\t\t%d\t\t%d\t\t%d", p[i], bt[i], wt[i], tat[i]);
}
avg_tat = (float)total / n;
printf("\nAverage Waiting time: %f", avg_wt);
printf("\nAverage turn around time: %f", avg_tat);
printf("\nAverage response time: %f", avg_wt);
return 0;
}
def cropImage(self, img):
grayscale = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
_,thresholded = cv2.threshold(grayscale, 0, 255, cv2.THRESH_OTSU)
#cv2.imwrite("otsu.png", thresholded)
bbox = cv2.boundingRect(thresholded)
x, y, w, h = bbox
#print(bbox)
croppedImg = img[y:y+h, x:x+w]
return croppedImg