From 0b930bb715fcfc231ee297ac2294c7f9402337b7 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 8 Mar 2012 15:32:23 -0800 Subject: [PATCH] libthreads: remove superfluous code The thread.started field is unnecessary for now. The initial getcontext() call is unecessary as well. swapcontext() is better for most instances where we are not creating a new thread. Remove question mark ('?') from last statement. --- libthreads.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libthreads.c b/libthreads.c index 5f442b2..4545ee3 100644 --- a/libthreads.c +++ b/libthreads.c @@ -20,7 +20,6 @@ struct thread { void *arg; ucontext_t context; void *stack; - int started; int index; }; @@ -44,7 +43,6 @@ int thread_create(struct thread *t, void (*start_routine), void *arg) t->start_routine = start_routine; t->arg = arg; - t->started = 0; /* Initialize state */ getcontext(&t->context); @@ -65,8 +63,6 @@ void thread_start(struct thread *t) { DBG(); - t->started = 1; - if (current) { struct thread *old = current; current = t; @@ -104,18 +100,15 @@ int main() { struct thread t; ucontext_t main_context; - int pass = 0; cleanup = &main_context; thread_create(&t, &user_main, NULL); - getcontext(&main_context); - if (!pass++) - thread_start(&t); + thread_start(&t); DBG(); - DEBUG("Exiting?\n"); + DEBUG("Exiting\n"); return 0; } -- 2.34.1