I don't actually need a replaceable scheduler; I need a scheduler that can
switch policies at will. Just remove this level of abstraction for now (it can
be added later if needed).
/* First thread created (system_thread) will have id 1 */
this->used_thread_id = 0;
/* Initialize default scheduler */
- this->scheduler = new DefaultScheduler();
+ this->scheduler = new Scheduler();
this->current_action = NULL;
}
#include "common.h"
#include "model.h"
-void DefaultScheduler::add_thread(struct thread *t)
+void Scheduler::add_thread(struct thread *t)
{
DEBUG("thread %d\n", t->id);
queue.push(t);
}
-struct thread *DefaultScheduler::next_thread(void)
+struct thread *Scheduler::next_thread(void)
{
if (queue.empty())
return NULL;
return current;
}
-struct thread *DefaultScheduler::get_current_thread(void)
+struct thread *Scheduler::get_current_thread(void)
{
return current;
}
#include "model.h"
class Scheduler {
-public:
- virtual void add_thread(struct thread *t) = 0;
- virtual struct thread * next_thread(void) = 0;
- virtual struct thread * get_current_thread(void) = 0;
-};
-
-class DefaultScheduler: public Scheduler {
public:
void add_thread(struct thread *t);
struct thread * next_thread(void);