Kernel: Keep track of a task's PPID
This commit is contained in:
parent
bdf1bb15a1
commit
a9d3bdba6f
@ -18,6 +18,7 @@ struct Task
|
||||
};
|
||||
|
||||
uint64_t id;
|
||||
uint64_t ppid;
|
||||
Context regs;
|
||||
|
||||
int64_t task_sleep = 0;
|
||||
|
@ -41,6 +41,8 @@ void sys_fork(Context* context)
|
||||
|
||||
child->address_space = parent->address_space.clone();
|
||||
|
||||
child->ppid = parent->id;
|
||||
|
||||
child->regs.rax = 0;
|
||||
context->rax = child->id;
|
||||
|
||||
|
@ -102,6 +102,7 @@ void Scheduler::add_kernel_task(const char* taskname, void (*task)(void))
|
||||
ASSERT(new_task);
|
||||
new_task->user_task = false;
|
||||
new_task->id = free_tid++;
|
||||
new_task->ppid = 0;
|
||||
new_task->regs.rip = (uint64_t)task;
|
||||
new_task->allocated_stack =
|
||||
(uint64_t)MemoryManager::get_pages(TASK_PAGES_IN_STACK); // 16 KB is enough for everyone, right?
|
||||
@ -128,6 +129,7 @@ Task* Scheduler::create_user_task()
|
||||
memset(&new_task->regs, 0, sizeof(Context));
|
||||
new_task->user_task = true;
|
||||
new_task->id = free_tid++;
|
||||
new_task->ppid = 0;
|
||||
new_task->task_sleep = 0;
|
||||
new_task->task_time = 0;
|
||||
new_task->cpu_time = 0;
|
||||
@ -152,9 +154,11 @@ long Scheduler::load_user_task(const char* filename)
|
||||
ASSERT(new_task);
|
||||
memset(&new_task->regs, 0, sizeof(Context));
|
||||
new_task->id = free_tid++;
|
||||
new_task->ppid = 0;
|
||||
if (!new_task->allocator.init())
|
||||
{
|
||||
delete new_task;
|
||||
free_tid--;
|
||||
Interrupts::pop();
|
||||
return -ENOMEM;
|
||||
}
|
||||
@ -173,6 +177,7 @@ long Scheduler::load_user_task(const char* filename)
|
||||
{
|
||||
new_task->address_space.destroy();
|
||||
delete new_task;
|
||||
free_tid--;
|
||||
ELFLoader::release_elf_image(image);
|
||||
VMM::switch_back_to_kernel_address_space();
|
||||
Interrupts::pop();
|
||||
|
Loading…
Reference in New Issue
Block a user