From 16a7f2bdf92d3f4b8a0817258f1369f2cff37ee1 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Thu, 8 Mar 2012 23:36:20 -0800 Subject: [PATCH] libthreads: fixups --- libthreads.c | 10 ++++------ libthreads.h | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libthreads.c b/libthreads.c index 6da8fbf..2326f3b 100644 --- a/libthreads.c +++ b/libthreads.c @@ -1,6 +1,5 @@ #include #include -#include //#define CONFIG_DEBUG @@ -48,10 +47,10 @@ static int create_initial_thread(struct thread *t) int thread_create(struct thread *t, void (*start_routine), void *arg) { static int created = 1; - ucontext_t local; DBG(); + memset(t, 0, sizeof(*t)); t->index = created++; DEBUG("create thread %d\n", t->index); @@ -84,15 +83,15 @@ void a(int *idx) void user_main() { struct thread t1, t2; - int i = 1, j = 2; + int i = 2, j = 3; thread_create(&t1, &a, &i); thread_create(&t2, &a, &j); - printf("user_main() is going to start 2 threads\n"); + printf("%s() is going to start 1 thread\n", __func__); thread_start(&t1); thread_start(&t2); - printf("user_main() is finished\n"); + printf("%s() is finished\n", __func__); } int main() @@ -103,7 +102,6 @@ int main() current = &main_thread; thread_create(&user_thread, &user_main, NULL); - thread_start(&user_thread); DBG(); diff --git a/libthreads.h b/libthreads.h index 8522871..1323cef 100644 --- a/libthreads.h +++ b/libthreads.h @@ -1,4 +1,8 @@ +#ifndef __LIBTHREADS_H__ +#define __LIBTHREADS_H__ + #include +#include #ifdef CONFIG_DEBUG #define DBG() do { printf("Here: %s, L%d\n", __func__, __LINE__); } while (0) @@ -18,3 +22,5 @@ struct thread { int thread_create(struct thread *t, void (*start_routine), void *arg); void thread_start(struct thread *t); + +#endif /* __LIBTHREADS_H__ */ -- 2.34.1