]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ipc_timeout.cpp
update
[l4.git] / kernel / fiasco / src / kern / ipc_timeout.cpp
1
2 INTERFACE:
3
4 #include "timeout.h"
5
6 class Receiver;
7
8 class IPC_timeout : public Timeout
9 {
10   friend class Jdb_list_timeouts;
11 };
12
13 IMPLEMENTATION:
14
15 #include "context.h"
16 #include "globals.h"
17 #include "receiver.h"
18 #include "thread_state.h"
19
20 /**
21  * IPC_timeout constructor
22  */
23 PUBLIC inline
24 IPC_timeout::IPC_timeout()
25 {}
26
27 /**
28  * IPC_timeout destructor
29  */
30 PUBLIC virtual inline NEEDS [IPC_timeout::owner, "receiver.h"]
31 IPC_timeout::~IPC_timeout()
32 {
33   owner()->set_timeout (0);     // reset owner's timeout field
34 }
35
36 PRIVATE inline NEEDS ["globals.h"]
37 Receiver *
38 IPC_timeout::owner()
39 {
40   // We could have saved our context in our constructor, but computing
41   // it this way is easier and saves space. We can do this as we know
42   // that IPC_timeouts are always created on the kernel stack of the
43   // owner context.
44
45   return reinterpret_cast<Receiver *>(context_of (this));
46 }
47
48 /**
49  * Timeout expiration callback function
50  * @return true if reschedule is necessary, false otherwise
51  */
52 PRIVATE
53 bool
54 IPC_timeout::expired()
55 {
56   Receiver * const _owner = owner();
57
58   // Set thread ready
59   _owner->state_change_dirty(~Thread_ipc_mask, Thread_ready | Thread_timeout);
60
61   // Flag reschedule if owner's priority is higher than the current
62   // thread's (own or timeslice-donated) priority.
63   return _owner->sched()->deblock(current_cpu(), current()->sched(), false);
64 }