3 * Timeslice infrastructure
6 INTERFACE [sched_fixed_prio]:
9 #include "member_offs.h"
12 #include "ready_queue_fp.h"
15 class Sched_context : public cxx::D_list_item
18 friend class Jdb_list_timeouts;
19 friend class Jdb_thread_list;
22 friend struct Jdb_thread_list_policy;
27 L4_sched_param_legacy legacy_fixed_prio;
28 L4_sched_param_fixed_prio fixed_prio;
32 typedef cxx::Sd_list<Sched_context> Fp_list;
34 class Ready_queue_base : public Ready_queue_fp<Sched_context>
37 void activate(Sched_context *s)
38 { _current_sched = s; }
39 Sched_context *current_sched() const { return _current_sched; }
40 void ready_enqueue(Sched_context *sc)
42 assert_kdb(cpu_lock.test());
44 // Don't enqueue threads which are already enqueued
45 if (EXPECT_FALSE (sc->in_ready_list()))
48 enqueue(sc, sc == current_sched());
52 Sched_context *_current_sched;
55 Context *context() const { return context_of(this); }
62 friend class Ready_queue_fp<Sched_context>;
66 IMPLEMENTATION [sched_fixed_prio]:
71 #include "std_macros.h"
79 Sched_context::Sched_context()
80 : _prio(Config::Default_prio),
81 _quantum(Config::Default_time_slice),
82 _left(Config::Default_time_slice)
87 * Return priority of Sched_context
91 Sched_context::prio() const
98 Sched_context::set(L4_sched_param const *_p)
100 Sp const *p = reinterpret_cast<Sp const *>(_p);
101 if (p->p.sched_class >= 0)
104 _prio = p->legacy_fixed_prio.prio;
105 if (p->legacy_fixed_prio.prio > 255)
108 _quantum = p->legacy_fixed_prio.quantum;
109 if (p->legacy_fixed_prio.quantum == 0)
110 _quantum = Config::Default_time_slice;
114 switch (p->p.sched_class)
116 case L4_sched_param_fixed_prio::Class:
117 _prio = p->fixed_prio.prio;
118 if (p->fixed_prio.prio > 255)
121 _quantum = p->fixed_prio.quantum;
122 if (p->fixed_prio.quantum == 0)
123 _quantum = Config::Default_time_slice;
127 return L4_err::ERange;
133 * Return remaining time quantum of Sched_context
137 Sched_context::left() const
142 PUBLIC inline NEEDS[Sched_context::set_left]
144 Sched_context::replenish()
145 { set_left(_quantum); }
148 * Set remaining time quantum of Sched_context
152 Sched_context::set_left(Unsigned64 left)
159 * Check if Context is in ready-list.
160 * @return 1 if thread is in ready-list, 0 otherwise
164 Sched_context::in_ready_list() const
166 return Fp_list::in_list(this);
171 Sched_context::dominates(Sched_context *sc)
172 { return prio() > sc->prio(); }