[kernel] Add thread_join syscall

Thread joining is an important primitive that I seem to have totally
forgotten to implement previously.
This commit is contained in:
Justin C. Miller
2022-10-20 21:58:10 -07:00
parent 194776d226
commit 2703080df2
4 changed files with 32 additions and 3 deletions

View File

@@ -52,6 +52,20 @@ thread::block()
return m_wake_value;
}
j6_status_t
thread::join()
{
if (has_state(state::exited))
return j6_status_ok;
thread &caller = current();
if (&caller == this)
return j6_err_invalid_arg;
m_join_queue.add_thread(&caller);
return caller.block();
}
void
thread::wake(uint64_t value)
{