]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/timeslice_timeout.cpp
update
[l4.git] / kernel / fiasco / src / kern / timeslice_timeout.cpp
1
2 INTERFACE:
3
4 #include "timeout.h"
5
6 class Timeslice_timeout : public Timeout
7 {
8 };
9
10 IMPLEMENTATION:
11
12 #include <cassert>
13 #include "globals.h"
14 #include "sched_context.h"
15 #include "std_macros.h"
16
17 /* Initialize global valiable timeslice_timeout */
18 DEFINE_PER_CPU Per_cpu<Timeout *> timeslice_timeout;
19 DEFINE_PER_CPU static Per_cpu<Timeslice_timeout> the_timeslice_timeout(true);
20
21 PUBLIC
22 Timeslice_timeout::Timeslice_timeout(Cpu_number cpu)
23 {
24   timeslice_timeout.cpu(cpu) = this;
25 }
26
27
28 /**
29  * Timeout expiration callback function
30  * @return true to force a reschedule
31  */
32 PRIVATE
33 bool
34 Timeslice_timeout::expired()
35 {
36   Sched_context::Ready_queue &rq = Sched_context::rq.current();
37   Sched_context *sched = rq.current_sched();
38
39   if (sched)
40     {
41 #if 0
42       Context *owner = sched->owner();
43
44       // Ensure sched is owner's current timeslice
45       assert (owner->sched() == sched);
46 #endif
47       sched->replenish();
48       rq.requeue(sched);
49       rq.invalidate_sched();
50
51 //      owner->switch_sched(sched);
52     }
53
54   return true;                          // Force reschedule
55 }