-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem.h
52 lines (44 loc) · 1.23 KB
/
system.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
/*
* system.h
*
* Created on: May 10, 2018
* Author: OS1
*/
#ifndef SYSTEM_H_
#define SYSTEM_H_
#include "symbols.h"
#include "pcb.h"
class KernelSem;
typedef void interrupt (*pInterrupt) (...);
class System { //in this class, we will have everything related to system operations
public:
static void interrupt timer ();
static void inic_system();
static void restore_system();
friend class PCB;
friend class Thread;
friend class KernelSem;
static void exit_thread();
volatile static PCB* running;
struct SleepingThreads {
PCB* mypcb; //sleeping thread's PCB
Time timeLeft;
SleepingThreads* next;
SleepingThreads(PCB* pcb, Time timeToSleep){
mypcb=pcb;
timeLeft=timeToSleep;
next=NULL;
}
};
static void addSleepingThread(Time timeToSleep); //adds a sleeping thread into a list
static void wakeThreadsUp();
private:
volatile static int counter;
volatile static boolean demanded_context_switch;
static pInterrupt oldISR; //old interrupt routine
volatile static PCB* mainThread; //main
volatile static int number_of_working_threads;
volatile static SleepingThreads* SleepingThreadsHead;
volatile static PCB* idleThread;
};
#endif /* SYSTEM_H_ */