X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=schedule.c;h=c8f54e84e493b2c591d53a3b33bafdc850d64022;hb=59aaf50bde2347f826259a1951a5af4bfca060e0;hp=4ac8b4991b37a70993a10485923c367bc847d4d2;hpb=c45f266119299ec579737b5911c1ab82e11d0bfc;p=model-checker.git diff --git a/schedule.c b/schedule.c index 4ac8b49..c8f54e8 100644 --- a/schedule.c +++ b/schedule.c @@ -15,6 +15,7 @@ struct thread_list_node { struct thread_list_node *head, *tail; struct thread_list_node nodes[NUM_LIST_NODES]; +struct thread *current; static void enqueue_thread(struct thread *t) { @@ -35,7 +36,7 @@ static void enqueue_thread(struct thread *t) tail = node; } -struct thread *dequeue_thread(void) +static struct thread *dequeue_thread(void) { struct thread *pop; @@ -48,30 +49,38 @@ struct thread *dequeue_thread(void) tail = NULL; head = head->next; + /* Set new current thread */ + current = pop; + return pop; } -void schedule_add_thread(struct thread *t) +static void default_add_thread(struct thread *t) { DEBUG("thread %d\n", t->index); enqueue_thread(t); } -struct thread *schedule_choose_next(void) +static struct thread *default_choose_next(void) { return dequeue_thread(); } +static struct thread *default_thread_current(void) +{ + return current; +} + void scheduler_init(struct model_checker *mod) { struct scheduler *sched; - /* Initialize FCFS scheduler */ + /* Initialize default 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; + sched->add_thread = default_add_thread; + sched->next_thread = default_choose_next; + sched->get_current_thread = default_thread_current; mod->scheduler = sched; }