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
|
struct Process* next; // Pointer to the next task in the list
|
||||||
} Process;
|
} Process;
|
||||||
|
|
||||||
//Process* task_create(EntryPoint func);
|
|
||||||
Process* task_create(EntryPoint func, void** args, uint32_t arg_count);
|
Process* task_create(EntryPoint func, void** args, uint32_t arg_count);
|
||||||
void scheduler_init();
|
void scheduler_init();
|
||||||
void schedule();
|
void schedule();
|
||||||
|
|||||||
+7
-5
@@ -21,7 +21,7 @@ static void processStartup()
|
|||||||
scheduler_unlock();
|
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));
|
Process* p = heap_alloc(sizeof(Process));
|
||||||
p->pid = ++pid_counter;
|
p->pid = ++pid_counter;
|
||||||
@@ -83,7 +83,7 @@ void schedule()
|
|||||||
Process* next = current->next;
|
Process* next = current->next;
|
||||||
if(!next)
|
if(!next)
|
||||||
next = queue;
|
next = queue;
|
||||||
|
if(next != current)
|
||||||
switchProcess(next);
|
switchProcess(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,10 +109,12 @@ void task2(int arg1, int arg2)
|
|||||||
|
|
||||||
void scheduler_init()
|
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"};
|
void* args1[] = {(void*)42, (void*)"ebalo"};
|
||||||
task_create((void (*)())&task1, args1, 2);
|
task_create((EntryPoint)&task1, args1, 2);
|
||||||
void* args2[] = {(void*)69, (void*)420};
|
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