-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPCB.cpp
More file actions
76 lines (60 loc) · 1.28 KB
/
PCB.cpp
File metadata and controls
76 lines (60 loc) · 1.28 KB
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
/*
* PCB.cpp
*
* Created on: Jun 3, 2015
* Author: OS1
*/
#include "PCB.h"
#include "Thread.h"
#include <dos.h>
#include <iostream.h>
#include "CompQue.h"
#include "util.h"
ID PCB::Id = 0;
PCB* PCB::running = 0;
PCB::PCB(StackSize st) {
id = 0;
s = st;
bp = sp = ss = 0;
stack = 0;
state = CREATED;
t = 10;
thr = 0;
complSem = 0;
proteklo_vreme = 0;
doTheFlop = 0;
}
PCB::PCB(StackSize st, Time ts, Thread* t) {
if(ts == 0) doTheFlop = 0;
else doTheFlop = 1;
id = ++Id;
thr = t;
this->complSem = new CompQue(this->id);
s = st;
this->t = ts;
bp = 0;
sp = 0;
ss = 0;
stack = 0;
state = CREATED;
proteklo_vreme = 0;
}
PCB::~PCB() {
if(this->id == 0) dispatch();
}
void PCB::createStack() {
stack = new unsigned[s];
#ifndef BCC_BLOCK_IGNORE
stack[s-1] = FP_SEG(thr);
stack[s-2] = FP_OFF(thr);
stack[s-5] = 0x200;
stack[s-6] = FP_SEG(Thread::wrapper);
stack[s-7] = FP_OFF(Thread::wrapper);
this->sp = FP_OFF(&stack[s - 16]); //SP treba da bude na ovom mestu (namestamo ga na to mesto)
this->bp = FP_OFF(&stack[s - 16]);
this->ss = FP_SEG(&stack[s - 16]); //SEG kupi segment od adrese koju prosledimo
#endif
}
void PCB::createKernelStack() {
stack = new unsigned[4096];
}