libthreads: remove superfluous code
authorBrian Norris <banorris@uci.edu>
Thu, 8 Mar 2012 23:32:23 +0000 (15:32 -0800)
committerBrian Norris <banorris@uci.edu>
Thu, 8 Mar 2012 23:32:23 +0000 (15:32 -0800)
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

index 5f442b20b1c6ac642f09f7888f055b74f076d7d7..4545ee3640a79a542e1c61f199bd37853c4c9231 100644 (file)
@@ -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;
 }