Use new and delete in Scheduler
This commit is contained in:
parent
ae9967c462
commit
d3527b8824
@ -43,8 +43,7 @@ void Scheduler::init()
|
|||||||
idle_task.task_sleep = 1000;
|
idle_task.task_sleep = 1000;
|
||||||
idle_task.state = idle_task.Idle;
|
idle_task.state = idle_task.Idle;
|
||||||
|
|
||||||
base_task = (Task*)kmalloc(sizeof(Task));
|
base_task = new Task;
|
||||||
memset(base_task, 0, sizeof(Task));
|
|
||||||
end_task = base_task;
|
end_task = base_task;
|
||||||
sched_current_task = base_task;
|
sched_current_task = base_task;
|
||||||
sched_current_task->id = free_tid++;
|
sched_current_task->id = free_tid++;
|
||||||
@ -60,9 +59,8 @@ void Scheduler::init()
|
|||||||
|
|
||||||
void Scheduler::add_kernel_task(void (*task)(void))
|
void Scheduler::add_kernel_task(void (*task)(void))
|
||||||
{
|
{
|
||||||
Task* new_task = (Task*)kmalloc(sizeof(Task));
|
Task* new_task = new Task;
|
||||||
ASSERT(new_task);
|
ASSERT(new_task);
|
||||||
memset(new_task, 0, sizeof(Task));
|
|
||||||
new_task->id = free_tid++;
|
new_task->id = free_tid++;
|
||||||
new_task->regs.rip = (uint64_t)task;
|
new_task->regs.rip = (uint64_t)task;
|
||||||
new_task->allocated_stack = (uint64_t)MemoryManager::get_pages(4); // 16 KB is enough for everyone, right?
|
new_task->allocated_stack = (uint64_t)MemoryManager::get_pages(4); // 16 KB is enough for everyone, right?
|
||||||
@ -86,7 +84,7 @@ void Scheduler::add_kernel_task(void (*task)(void))
|
|||||||
|
|
||||||
void Scheduler::add_user_task(void* task)
|
void Scheduler::add_user_task(void* task)
|
||||||
{
|
{
|
||||||
Task* new_task = (Task*)kmalloc(sizeof(Task));
|
Task* new_task = new Task;
|
||||||
ASSERT(new_task);
|
ASSERT(new_task);
|
||||||
new_task->id = free_tid++;
|
new_task->id = free_tid++;
|
||||||
new_task->regs.rip = (uint64_t)task;
|
new_task->regs.rip = (uint64_t)task;
|
||||||
@ -116,7 +114,7 @@ void Scheduler::reap_task(Task* task)
|
|||||||
Task* exiting_task = task;
|
Task* exiting_task = task;
|
||||||
kinfoln("reaping task %ld", exiting_task->id);
|
kinfoln("reaping task %ld", exiting_task->id);
|
||||||
if (exiting_task->allocated_stack) MemoryManager::release_pages((void*)exiting_task->allocated_stack, 4);
|
if (exiting_task->allocated_stack) MemoryManager::release_pages((void*)exiting_task->allocated_stack, 4);
|
||||||
kfree((void*)exiting_task);
|
delete exiting_task;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::task_exit(Context* context)
|
void Scheduler::task_exit(Context* context)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user