From: Brian Norris Date: Tue, 13 Mar 2012 05:28:14 +0000 (-0700) Subject: libthreads: separate private functions from user interface X-Git-Tag: pldi2013~589 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fc783f845414d3e60b8d2648bfbb3f50bb1e021b;p=model-checker.git libthreads: separate private functions from user interface --- diff --git a/libthreads.c b/libthreads.c index 4233c0e..6a549d4 100644 --- a/libthreads.c +++ b/libthreads.c @@ -55,17 +55,6 @@ static int thread_swap(struct thread *old, struct thread *new) return swapcontext(&old->context, &new->context); } -int thread_yield(void) -{ - struct thread *old, *next; - - DBG(); - old = thread_current(); - old->state = THREAD_READY; - next = model->system_thread; - return thread_swap(old, next); -} - static void thread_dispose(struct thread *t) { DEBUG("completed thread %d\n", thread_current()->index); @@ -107,6 +96,9 @@ static void thread_wait_finish(void) while (!thread_system_next()); } +/* + * User program API functions + */ int thread_create(struct thread *t, void (*start_routine), void *arg) { static int created = 1; @@ -138,11 +130,25 @@ void thread_join(struct thread *t) thread_yield(); } +int thread_yield(void) +{ + struct thread *old, *next; + + DBG(); + old = thread_current(); + old->state = THREAD_READY; + next = model->system_thread; + return thread_swap(old, next); +} + struct thread *thread_current(void) { return model->scheduler->get_current_thread(); } +/* + * Main system function + */ int main() { struct thread user_thread;