3 #include "libthreads.h"
8 struct thread_list_node {
10 struct thread_list_node *next;
14 #define NUM_LIST_NODES 32
16 struct thread_list_node *head, *tail;
17 struct thread_list_node nodes[NUM_LIST_NODES];
19 static void enqueue_thread(struct thread *t)
22 struct thread_list_node *node;
24 for (node = nodes, i = 0; node->live && i < NUM_LIST_NODES; i++, node++);
25 if (i >= NUM_LIST_NODES)
26 printf("ran out of nodes\n");
38 struct thread *dequeue_thread(void)
54 void schedule_add_thread(struct thread *t)
56 DEBUG("thread %d\n", t->index);
60 struct thread *schedule_choose_next(void)
62 return dequeue_thread();
65 void scheduler_init(struct model_checker *mod)
67 struct scheduler *sched;
69 /* Initialize FCFS scheduler */
70 sched = malloc(sizeof(*sched));
73 sched->add_thread = schedule_add_thread;
74 sched->next_thread = schedule_choose_next;
75 sched->get_current_thread = thread_current;
76 mod->scheduler = sched;