diff --git a/include/task.h b/include/task.h index 5c5cf90..f1cec7e 100644 --- a/include/task.h +++ b/include/task.h @@ -24,7 +24,6 @@ typedef struct Process struct Process* next; // Pointer to the next task in the list } Process; -//Process* task_create(EntryPoint func); Process* task_create(EntryPoint func, void** args, uint32_t arg_count); void scheduler_init(); void schedule(); diff --git a/src/task.c b/src/task.c index b577a3e..e37167d 100644 --- a/src/task.c +++ b/src/task.c @@ -21,7 +21,7 @@ static void processStartup() scheduler_unlock(); } -Process* task_create(void(*func)(), void** args, uint32_t arg_count) +Process* task_create(EntryPoint func, void** args, uint32_t arg_count) { Process* p = heap_alloc(sizeof(Process)); p->pid = ++pid_counter; @@ -83,8 +83,8 @@ void schedule() Process* next = current->next; if(!next) next = queue; - - switchProcess(next); + if(next != current) + switchProcess(next); } void idle() @@ -109,10 +109,12 @@ void task2(int arg1, int arg2) void scheduler_init() { - task_create(&idle, NULL, 0); + //we create this task two times because in other case it just won't start + task_create((EntryPoint)&idle, NULL, 0); + task_create((EntryPoint)&idle, NULL, 0); void* args1[] = {(void*)42, (void*)"ebalo"}; - task_create((void (*)())&task1, args1, 2); + task_create((EntryPoint)&task1, args1, 2); void* args2[] = {(void*)69, (void*)420}; - task_create((void (*)())&task2, args2, 2); + task_create((EntryPoint)&task2, args2, 2); }