schedule: add replaceable scheduler struct
[model-checker.git] / schedule.c
index d567dd7fd5799f3723acf3d2ff678fa3471e6cea..4ac8b4991b37a70993a10485923c367bc847d4d2 100644 (file)
@@ -1,6 +1,9 @@
+#include <stdlib.h>
+
 #include "libthreads.h"
 #include "schedule.h"
 #include "common.h"
+#include "model.h"
 
 struct thread_list_node {
        struct thread *this;
@@ -58,3 +61,17 @@ struct thread *schedule_choose_next(void)
 {
        return dequeue_thread();
 }
+
+void scheduler_init(struct model_checker *mod)
+{
+       struct scheduler *sched;
+
+       /* Initialize FCFS scheduler */
+       sched = malloc(sizeof(*sched));
+       sched->init = NULL;
+       sched->exit = NULL;
+       sched->add_thread = schedule_add_thread;
+       sched->next_thread = schedule_choose_next;
+       sched->get_current_thread = thread_current;
+       mod->scheduler = sched;
+}