#include "model.h"
struct thread_list_node {
- struct thread *this;
+ struct thread *t;
struct thread_list_node *next;
int live;
};
struct thread_list_node *node;
for (node = nodes, i = 0; node->live && i < NUM_LIST_NODES; i++, node++);
- if (i >= NUM_LIST_NODES)
+ if (i >= NUM_LIST_NODES) {
printf("ran out of nodes\n");
- node->this = t;
+ exit(1);
+ }
+ node->t = t;
node->next = NULL;
node->live = 1;
if (!head)
return NULL;
- pop = head->this;
+ pop = head->t;
head->live = 0;
if (head == tail)
tail = NULL;
return pop;
}
-static void default_add_thread(struct thread *t)
+void DefaultScheduler::add_thread(struct thread *t)
{
- DEBUG("thread %d\n", t->index);
+ DEBUG("thread %d\n", t->id);
enqueue_thread(t);
}
-static struct thread *default_choose_next(void)
+struct thread *DefaultScheduler::next_thread(void)
{
return dequeue_thread();
}
-static struct thread *default_thread_current(void)
+struct thread *DefaultScheduler::get_current_thread(void)
{
return current;
}
-
-void scheduler_init(struct model_checker *mod)
-{
- struct scheduler *sched;
-
- /* Initialize default scheduler */
- sched = malloc(sizeof(*sched));
- sched->init = NULL;
- sched->exit = NULL;
- sched->add_thread = default_add_thread;
- sched->next_thread = default_choose_next;
- sched->get_current_thread = default_thread_current;
- mod->scheduler = sched;
-}