diff --git a/app b/app new file mode 100644 index 0000000..571d81e Binary files /dev/null and b/app differ diff --git a/context.o b/context.o new file mode 100644 index 0000000..5ef3098 Binary files /dev/null and b/context.o differ diff --git a/thread.c b/thread.c index 4a544f5..d1ab65a 100644 --- a/thread.c +++ b/thread.c @@ -48,6 +48,37 @@ static void schedule1() // push the current thread to the end of the ready list void create_thread(func_t func, void *param) { + unsigned *stack = malloc(4096); + stack += 1024; + struct thread *t = malloc(sizeof(struct thread)); + + stack=(stack-(sizeof(unsigned)/4)); + *stack=(unsigned)param; // parameter + + stack=(stack-(sizeof(unsigned)/4)); + *stack=0; + + stack=(stack-(sizeof(unsigned)/4)); + *stack=(unsigned)func; + + stack=(stack-(sizeof(unsigned)/4)); + *stack=0; + + stack=(stack-(sizeof(unsigned)/4)); + *stack=0; + + stack=(stack-(sizeof(unsigned)/4)); + *stack=0; + + stack=(stack-(sizeof(unsigned)/4)); + *stack=0; + + + t->esp=stack;// set esp in struct thread (t) + + push_back(t); + //schedule1(); + } // call schedule1 diff --git a/thread.o b/thread.o new file mode 100644 index 0000000..790c0c1 Binary files /dev/null and b/thread.o differ