#include "ready_queue_fp.h"
#include "ready_queue_wfq.h"
-
class Sched_context
{
MEMBER_OFFSET();
friend class Jdb_list_timeouts;
friend class Jdb_thread_list;
-public:
- enum Type { Fixed_prio, Wfq };
-
- struct Ready_queue
+ struct Ready_list_item_concept
{
- public:
- Ready_queue_fp<Sched_context> fp_rq;
- Ready_queue_wfq<Sched_context> wfq_rq;
- Context *schedule_in_progress;
- Sched_context *current_sched() const { return _current_sched; }
- void activate(Sched_context *s)
- {
- if (s && s->_t == Wfq)
- wfq_rq.activate(s);
- _current_sched = s;
- }
-
- private:
- Sched_context *_current_sched;
-
- friend class Jdb_thread_list;
-
- public:
- void set_idle(Sched_context *sc)
- { sc->_t = Wfq; sc->_sc.wfq._p = 0; wfq_rq.set_idle(sc); }
-
- void enqueue(Sched_context *);
- void dequeue(Sched_context *);
- Sched_context *next_to_run() const;
+ typedef Sched_context Item;
+ static Sched_context *&next(Sched_context *e) { return e->_sc.fp._ready_next; }
+ static Sched_context *&prev(Sched_context *e) { return e->_sc.fp._ready_prev; }
+ static Sched_context const *next(Sched_context const *e)
+ { return e->_sc.fp._ready_next; }
+ static Sched_context const *prev(Sched_context const *e)
+ { return e->_sc.fp._ready_prev; }
};
- Context *context() const { return context_of(this); }
+public:
+ enum Type { Fixed_prio, Wfq };
-private:
+ typedef cxx::Sd_list<Sched_context, Ready_list_item_concept> Fp_list;
- unsigned short _p;
+private:
Type _t;
struct B_sc
struct Fp_sc : public B_sc
{
- Sched_context *_ready_next;
- Sched_context *_ready_prev;
+ Sched_context *_ready_next, *_ready_prev;
};
struct Wfq_sc : public B_sc
Sc _sc;
-
public:
static Wfq_sc *wfq_elem(Sched_context *x) { return &x->_sc.wfq; }
- static Fp_sc *fp_elem(Sched_context *x) { return &x->_sc.fp; }
+ struct Ready_queue
+ {
+ public:
+ Ready_queue_fp<Sched_context> fp_rq;
+ Ready_queue_wfq<Sched_context> wfq_rq;
+ Context *schedule_in_progress;
+ Sched_context *current_sched() const { return _current_sched; }
+ void activate(Sched_context *s)
+ {
+ if (s && s->_t == Wfq)
+ wfq_rq.activate(s);
+ _current_sched = s;
+ }
+
+ private:
+ Sched_context *_current_sched;
+
+ friend class Jdb_thread_list;
+
+ public:
+ void set_idle(Sched_context *sc)
+ { sc->_t = Wfq; sc->_sc.wfq._p = 0; wfq_rq.set_idle(sc); }
+
+ void enqueue(Sched_context *);
+ void dequeue(Sched_context *);
+ Sched_context *next_to_run() const;
+ };
+
+ Context *context() const { return context_of(this); }
};
Sched_context::Sched_context()
{
_t = Fixed_prio;
- _sc.fp._p = Config::default_prio;
- _sc.fp._q = Config::default_time_slice;
- _sc.fp._left = Config::default_time_slice;
+ _sc.fp._p = Config::Default_prio;
+ _sc.fp._q = Config::Default_time_slice;
+ _sc.fp._left = Config::Default_time_slice;
_sc.fp._ready_next = 0;
}
Mword
Sched_context::in_ready_list() const
{
+ // this magically works for the fp list and the heap,
+ // because wfq._ready_link and fp._ready_next are the
+ // same memory location
return _sc.wfq._ready_link != 0;
}