Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app
Binary file not shown.
Binary file added context.o
Binary file not shown.
31 changes: 31 additions & 0 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added thread.o
Binary file not shown.