-
Notifications
You must be signed in to change notification settings - Fork 0
/
KrnlEv.cpp
63 lines (53 loc) · 1 KB
/
KrnlEv.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
/*
* KrnlEv.cpp
*
* Created on: Jun 21, 2021
* Author: OS1
*/
#include "KrnlEv.h"
#include "Kernel.h"
#include "IVTEntry.h"
#include "pcb.h"
#include "Schedule.h"
//#include <iostream.h>
KrnlEv::KrnlEv(IVTNo ivtNumberr) {
lock
isBlocked = 0;
ivtNumber = ivtNumberr;
Kernel::ivtEntries[ivtNumberr]->event = this; //IVTentryju pridruzujemo ovaj event
myPCB = (PCB*)Kernel::runningPCB; //running PCB pravi event
unlock
}
void KrnlEv::wait() {
lock
if(isBlocked || myPCB != Kernel::runningPCB){
unlock
return;
}
//isBlocked = 0 i myPCB jeste runningPCB
myPCB->status = BLOCKED;
isBlocked = 1;
unlock
/*lock
cout << "Kernel.dispatch";
unlock*/
Kernel::dispatch();
}
void KrnlEv::signal(){
lock
if(!isBlocked){
unlock
return;
}
//blokirana je
myPCB->status = READY;
isBlocked = 0;
Scheduler::put(myPCB);
Kernel::dispatch();
unlock
}
KrnlEv::~KrnlEv() {
lock
Kernel::ivtEntries[ivtNumber]->event = 0;
unlock
}