-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kernel.h
58 lines (35 loc) · 1.23 KB
/
Kernel.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
/*
* Kernel.h
*
* Created on: Jun 1, 2021
* Author: OS1
*/
#include "List.h"
#ifndef KERNEL_H_
#define KERNEL_H_
typedef void interrupt (*pInterrupt)(...);
typedef unsigned int Time; // time, x 55ms
class PCB;
class IdleThr;
class KernelSem;
class IVTEntry;
#define lock Kernel::lockFlag=0;
#define unlock Kernel::lockFlag=1; if(Kernel::requestedContextChange) Kernel::dispatch();
class Kernel{
friend void interrupt timer(...);
public:
static IVTEntry * ivtEntries[256];
static IdleThr * idleThread;
static volatile char currentUnlimited;
static LList<PCB> allPCBs;
static LList<KernelSem> allSems;
static volatile char lockFlag; //valjda moze char, volatile jer ga koristi vise niti da ne bude optimizacije
static volatile char requestedContextChange; //koristi vise niti, volatile => nema optimizacije !!
//da li da cuvamo sve pcbove pa da ih brisemo posle ?
volatile static PCB * runningPCB; //volatile ?? -ne zelimo optimizaciju!
static Time runningTimeSlice;
static void dispatch(); //sinhrona promena konteksta
static void init(); //inicijalizuj novu prekidnu rutinu
static void restore(); //vrati staru prekidnu rutinu
};
#endif /* KERNEL_H_ */