-
Notifications
You must be signed in to change notification settings - Fork 0
/
lab_11.c
49 lines (41 loc) · 983 Bytes
/
lab_11.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
#include<stdio.h>
void main()
{
int N_proc,i,wait_prev,k,temp,m,l;
wait_prev=0;
printf("\nEnter the no of processes:");
scanf("%d",&N_proc);
int burst[N_proc],wait[N_proc],turnarnd[N_proc],proc[N_proc];
for(i=0;i<N_proc;i++)
{
printf("\nEnter burst time for process %d:",i+1);
scanf("%d",&burst[i]);
}
//sorting processes according to their burst time
int min =100;
int flag[N_proc];
for(i=0;i<N_proc;i++)
flag[i]=0;
int index;
for(i=0;i<N_proc;i++)
{
min = 1000;
for(k=0;k<N_proc;k++)
{
if(flag[k]!=1 && min>burst[k])
{
min = burst[k];
index = k;
}
}
//printf("%d index \n", index);
wait[index]=wait_prev;
turnarnd[index]=wait[index]+burst[index];
//wait_prev=wait_prev+burst[i];
wait_prev+=burst[index];
flag[index]=1;
printf("\n Process: %d burst time = %d wait time = %d turnaround time = %d\n",index+1,burst[index],wait[index],turnarnd[index]);
}
getchar();
getchar();
}