-
Notifications
You must be signed in to change notification settings - Fork 0
/
PCB.h
61 lines (52 loc) · 1.04 KB
/
PCB.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
#ifndef _PCB_h_
#define _PCB_h_
#include "List.h"
class Semaphore;
class Thread;
class List;
class PCB
{
public:
PCB(unsigned long stackSize,
unsigned int timeSlice,
Thread* myThread);
~PCB();
void start();
void waitToComplete();
void sleep(unsigned int timeToSleep);
void goFromIdleThreadToMainFunction();
//private:
void run();
static void wrapperRun();
friend class Timer;
friend class List;
friend class KernelSemaphore;
static int noMoreTime;
static int mustSwitchContext;
static PCB* runningPCB;
static PCB* mainPCB;
static PCB* idlePCB;
static List* blockedPCB;
static List* terminatedPCB;
static List* allPCB;
enum State
{
NEW,
RUNNING,
BLOCKED,
READY,
TERMINATED,
};
unsigned long stackSize;
unsigned stackPointer;
unsigned stackSegment;
State state;
unsigned int timeToSleep;
unsigned int timeToRun;
unsigned int timeSlice;
unsigned int* stack;
Semaphore* semaphore;
unsigned int id;
Thread* myThread;
};
#endif