-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
44 lines (37 loc) · 983 Bytes
/
main.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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sched.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include "process.h"
#include "process_control.h"
#define FIFO 1
#define RR 2
#define SJF 3
#define PSJF 4
int main()
{
int policy, Num_of_Process;
char buffer[8];
struct Process *process;
scanf("%s%d", buffer, &Num_of_Process);
if(strcmp(buffer, "FIFO") == 0)
policy = FIFO;
else if(strcmp(buffer, "RR") == 0)
policy = RR;
else if(strcmp(buffer, "SJF") == 0)
policy = SJF;
else if(strcmp(buffer, "PSJF") == 0)
policy = PSJF;
else
{
fprintf(stderr, "wrong policy type\n");
exit(0);
}
process = (struct Process *)malloc(Num_of_Process * sizeof(struct Process));
for(int i = 0 ; i < Num_of_Process; i++)
scanf("%s%d%d", process[i].name, &process[i].ready_time, &process[i].execu_time);
Scheduling(process, Num_of_Process, policy);
}