-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscheduler.h
127 lines (85 loc) · 2.62 KB
/
scheduler.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
10/28/2017
Authors: Connor Lundberg, Jacob Ackerman
In this project we will be making an MLFQ scheduling algorithm
that will take a PriorityQueue of PCBs and run them through our scheduler.
It will simulate the "running" of the process by incrementing the running PCB's PCB
by one on each loop through. It will also incorporate various interrupts to show
the effects it has on the scheduling simulator.
This file holds the definitions of structs and declarations functions for the
scheduler.c file.
*/
#ifndef SCHEDULER_H
#define SCHEDULER_H
//includes
#include "priority_queue.h"
#include "mutex_map.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//defines
#define MAX_PCB_TOTAL 300
#define RESET_COUNT 5
#define MAX_MUTEX_IN_ROUND 3
#define MAX_PC_JUMP 4000
#define MIN_PC_JUMP 3000
#define PC_JUMP_LIMIT 999
#define MAKE_PCB_CHANCE_DOMAIN 100
#define TIMER_RANGE 3
#define MAKE_PCB_CHANCE_PERCENTAGE 40
#define IS_TIMER 1
#define IS_IO_TRAP 2
#define IS_IO_INTERRUPT 3
#define IS_TERMINATING -1
#define SWITCH_CALLS 4
#define MAX_VALUE_PRIVILEGED 15
#define RANDOM_VALUE 101
#define TOTAL_TERMINATED 5
#define MAX_PRIVILEGE 4
#define DEADLOCK 0
//structs
typedef struct scheduler {
ReadyQueue created;
ReadyQueue killed;
ReadyQueue blocked;
ReadyQueue killedMutexes;
MutexMap mutexes;
PriorityQueue ready;
PCB running;
PCB interrupted;
int isNew;
} scheduler_s;
typedef scheduler_s * Scheduler;
//declarations
int makePCBList (Scheduler);
unsigned int runProcess (unsigned int, int);
void pseudoISR (Scheduler, int);
void scheduling (int, Scheduler);
void dispatcher (Scheduler);
void pseudoIRET (Scheduler);
void printSchedulerState (Scheduler);
Scheduler schedulerConstructor ();
void schedulerDeconstructor (Scheduler);
int isPrivileged(PCB pcb);
void terminate(Scheduler theScheduler);
void resetMLFQ(Scheduler theScheduler);
void resetReadyQueue (ReadyQueue queue);
void osLoop ();
int timerInterrupt (int);
int ioTrap (PCB);
int ioInterrupt (ReadyQueue);
void incrementRoleCount (enum pcb_type);
void displayRoleCountResults();
void handleKilledQueueInsertion (Scheduler theScheduler);
void handleKilledQueueEmptying (Scheduler theScheduler);
void lockAttempt(Scheduler theScheduler, int mutexVal);
void unlockAttempt(Scheduler theScheduler, int mutexVal);
int useMutex (Scheduler thisScheduler);
int isLockPC (unsigned int pc, PCB pcb);
int isUnlockPC (unsigned int pc, PCB pcb);
int isSignalPC (unsigned int pc, PCB pcb);
int isWaitPC (unsigned int pc, PCB pcb);
void toStringMutexTraps(PCB newPCB1, PCB newPCB2);
void deadlockMonitor(Scheduler thisScheduler);
#endif