[kernel] Remove process & thread self-handles
For the coming switch to cap/handle ref-counting being the main lifetime determiner of objects, get rid of self handles for threads and processes to avoid circular references. Instead, passing 0 to syscalls expecting a thread or process handle signifies "this process/thread".
This commit is contained in:
@@ -17,9 +17,14 @@ thread_create(j6_handle_t *self, process *proc, uintptr_t stack_top, uintptr_t e
|
||||
thread &parent_th = thread::current();
|
||||
process &parent_pr = parent_th.parent();
|
||||
|
||||
if (!proc)
|
||||
proc = &parent_pr;
|
||||
|
||||
thread *child = proc->create_thread(stack_top);
|
||||
child->add_thunk_user(entrypoint, arg0, arg1);
|
||||
*self = child->self_handle();
|
||||
|
||||
*self = g_cap_table.create(child, thread::creation_caps);
|
||||
|
||||
child->set_state(thread::state::ready);
|
||||
|
||||
log::verbose(logs::task, "Thread <%02lx:%02lx> spawned new thread <%02lx:%02lx>",
|
||||
|
||||
@@ -31,14 +31,16 @@ vma_create_map(j6_handle_t *self, size_t size, uintptr_t base, uint32_t flags)
|
||||
j6_status_t
|
||||
vma_map(vm_area *self, process *proc, uintptr_t base)
|
||||
{
|
||||
proc->space().add(base, self);
|
||||
vm_space &space = proc ? proc->space() : process::current().space();
|
||||
space.add(base, self);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
j6_status_t
|
||||
vma_unmap(vm_area *self, process *proc)
|
||||
{
|
||||
proc->space().remove(self);
|
||||
vm_space &space = proc ? proc->space() : process::current().space();
|
||||
space.remove(self);
|
||||
return j6_status_ok;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user