tasking: fix idle task creation & make task_create take EntryPoint type argument
This commit is contained in:
@@ -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();
|
||||
|
||||
+7
-5
@@ -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,7 +83,7 @@ void schedule()
|
||||
Process* next = current->next;
|
||||
if(!next)
|
||||
next = queue;
|
||||
|
||||
if(next != current)
|
||||
switchProcess(next);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user