-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhelper.h
79 lines (69 loc) · 1.98 KB
/
helper.h
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
#define printable(a) (((a) >= 32 && (a) <= 126) || (a) == '\t' || (a) == '\n')
#define MAX_PROCESSES 100
#define MAX_BURSTS 1000
#define MAX_TOKEN_LENGTH 30
#define MAX_LINE_LENGTH (1<<16)
#define NUMBER_OF_PROCESSORS 4
#define NUMBER_OF_LEVELS 3
#define COMMENT_CHAR '#'
#define COMMENT_LINE -1
typedef struct burst{
int length;
int step;
} Burst;
typedef struct process{
int pid;
int arrivalTime;
int startTime;
int endTime;
int waitingTime;
int currentBurst;
int numOfBursts;
struct burst bursts[MAX_BURSTS];
int priority;
int quantumRemaining;
int currentQueue;
} Process;
typedef struct process_node{
struct process *data;
struct process_node *next;
} Process_node;
typedef struct process_queue{
int size;
struct process_node *front;
struct process_node *back;
} Process_queue;
/* Error management functions */
void error(char *);
void error_malformed_input_line(char *);
void error_too_many_bursts(int);
void error_duplicate_pid(int pid);
void error_bad_quantum(void);
void error_invalid_number_of_processes(int numberOfProcesses);
/* Scheduling functions */
double averageWaitTime(int theWait);
double averageTurnaroundTime(int theTurnaround);
double averageUtilizationTime(int theUtilization);
Process *nextScheduledProcess(void);
int compareArrivalTime(const void *a, const void *b);
int runningProcesses(void);
void addNewIncomingProcess(void);
int totalIncomingProcesses(void);
void waitingToReady(void);
void readyToRunning(void);
void runningToWaiting(void);
void displayResults(float awt, float atat, int sim, float aut, int cs, int pid);
void resetVariables(void);
void updateStates(void);
/* Queue management functions */
Process_node *createProcessNode(Process *);
void initializeProcessQueue(Process_queue *);
void enqueueProcess(Process_queue *, Process *);
void dequeueProcess(Process_queue *);
/* Input/Output functions */
char *readLine(void);
char *readLineHelper(char *, int);
int readInt(char **);
int readBracedInt(char **);
int empty(char *);
int readProcess(Process *);