-
Notifications
You must be signed in to change notification settings - Fork 0
/
proc.cpp
83 lines (67 loc) · 1.77 KB
/
proc.cpp
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
#include<proc.h>
uint32_t numProc = 0;
/****************************************************************************************************
* PROC IMPLEMENTATION
****************************************************************************************************/
Proc::Proc(uint32_t PID, bool isKproc) {
this->PID = PID;
this->isKern = isKproc;
if (isKproc) {
this->stack = 0x0;
}
else {
//TODO figure out how to do user level memory
}
this->state = EMBRIO;
this->PID = numProc;
numProc++;
}
Proc::~Proc() {
// TODO, once user stacks have been defined, we will need to free them.
// we will also need to decide how to manage Procs in the Ptable. Likely
// make sure it's contiguous on removal... Probably best to have this
// management mechanism in a Ptable method.
// I don't know why I didn't make this a comment block....
this->state = FREE;
}
/*
* GETTERS
*/
uint32_t Proc::getPID() {
return this->PID;
}
ProcState Proc::getState() {
return this->state;
}
bool Proc::isKproc() {
return this->isKern;
}
uint32_t Proc::getStackPTR() {
return this->stack;
}
/*
* SETTERS
* Note: As of now, I don't see a reason to allow anyone to modify isKern, so there is no setter
*/
bool Proc::setPID(uint32_t PID) {
if (this->state == FREE) {
return false;
}
this->PID = PID;
return true;
}
bool Proc::setState(ProcState state) {
this->state = state;
return true;
}
bool Proc::setStack(uint32_t stack) {
if (this->state == FREE) {
return false;
}
this->stack = stack;
return true;
}
/****************************************************************************************************
* PTABLE IMPLEMENTATION
****************************************************************************************************/
// TODO need a timming linked list library first