add: kernel task
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#include "task.h"
|
||||
#include "alloc.h"
|
||||
#include "debug.h"
|
||||
#include "kpanic.h"
|
||||
#include "kprintf.h"
|
||||
#include "memory.h"
|
||||
|
||||
uint32_t eip_backup;
|
||||
@ -21,6 +23,20 @@ static struct task *create_task(uint8_t owner_id)
|
||||
return new_task;
|
||||
}
|
||||
|
||||
int create_kernel_task(void)
|
||||
{
|
||||
struct task *new_task = vmalloc(sizeof(struct task));
|
||||
if (!new_task)
|
||||
return 1;
|
||||
new_task->owner_id = 0;
|
||||
new_task->pid = 0;
|
||||
new_task->heap = page_directory;
|
||||
new_task->prev = new_task;
|
||||
new_task->next = new_task;
|
||||
current_task = new_task;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exec_fn(void (*fn)(void))
|
||||
{
|
||||
struct task *new_task = create_task(OWNER_KERNEL);
|
||||
@ -28,13 +44,9 @@ void exec_fn(void (*fn)(void))
|
||||
kpanic("failed to create new task");
|
||||
new_task->status = RUN;
|
||||
new_task->eip = (uint32_t *)fn;
|
||||
new_task->next = current_task;
|
||||
new_task->prev = new_task;
|
||||
if (current_task) {
|
||||
new_task->prev = current_task->prev;
|
||||
current_task->prev = new_task;
|
||||
}
|
||||
current_task = new_task;
|
||||
new_task->prev = current_task;
|
||||
new_task->next = current_task->next;
|
||||
current_task->next = new_task;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user