-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent.h
45 lines (38 loc) · 916 Bytes
/
event.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
// File: event.h
// Uros Bojanic 2019/0077
#ifndef EVENT_H_
#define EVENT_H_
// Preprocessor directives
#include "IVTEntry.h"
#define PREPAREENTRY(ivtNo, callOld) \
void interrupt newISR##ivtNo(...); \
IVTEntry entry##ivtNo(ivtNo, newISR##ivtNo); \
void interrupt newISR##ivtNo(...) { \
if (callOld) { \
entry##ivtNo.oldISR_invoke(); \
} \
entry##ivtNo.signal(); \
dispatch(); \
} \
// Interrupt Vector Table Entry number
typedef unsigned char IVTNo;
// Kernel implementation of the event
class KernelEv;
// Event
class Event {
public:
// Constructor - makes an event
Event(IVTNo ivtNo);
// Destructor - deletes an event
~Event();
// Wait operation (can only be called by owner thread)
void wait();
protected:
friend class KernelEv;
// Signal operation (can call KernelEv)
void signal();
private:
// Kernel implementation of event (1-1 association)
KernelEv* myImpl;
};
#endif /* EVENT_H_ */