mirror of
https://github.com/justinian/jsix.git
synced 2025-12-11 08:54:31 -08:00
[kernel] Add userspace threading
Implement the syscalls necessary for threads to create other threads in their same process. This involved rearranging a number of syscalls, as well as implementing object_wait and a basic implementation of a process' list of handles.
This commit is contained in:
@@ -2,24 +2,32 @@
|
||||
#include "j6/types.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "objects/process.h"
|
||||
#include "objects/thread.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
namespace syscalls {
|
||||
|
||||
j6_status_t
|
||||
object_noop()
|
||||
object_wait(j6_handle_t handle, j6_signal_t mask, j6_signal_t *sigs)
|
||||
{
|
||||
auto &s = scheduler::get();
|
||||
TCB *tcb = s.current();
|
||||
thread *th = thread::from_tcb(tcb);
|
||||
log::debug(logs::syscall, "Thread %llx called noop syscall.", th->koid());
|
||||
return j6_status_ok;
|
||||
}
|
||||
scheduler &s = scheduler::get();
|
||||
thread *th = thread::from_tcb(s.current());
|
||||
process &p = th->parent();
|
||||
|
||||
j6_status_t
|
||||
object_wait(j6_handle_t, j6_signal_t, j6_signal_t*)
|
||||
{
|
||||
return j6_err_nyi;
|
||||
kobject *obj = p.lookup_handle(handle);
|
||||
if (!obj)
|
||||
return j6_err_invalid_arg;
|
||||
|
||||
obj->add_blocked_thread(th);
|
||||
th->wait_on_signals(obj, mask);
|
||||
s.schedule();
|
||||
|
||||
j6_status_t result = th->get_wait_result();
|
||||
if (result == j6_status_ok) {
|
||||
*sigs = th->get_wait_data();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace syscalls
|
||||
|
||||
Reference in New Issue
Block a user