[kernel] Add object_signal system call

Add a system call to assert signals on a given object, only within the
range of user-settable signals. Also made object_wait return
immediately if any of the given signals are already set.
This commit is contained in:
2020-07-26 18:03:30 -07:00
parent d3e9d92466
commit 58bc5acb1e
6 changed files with 48 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
#include "j6/errors.h"
#include "j6/signals.h"
#include "j6/types.h"
#include "log.h"
@@ -19,6 +20,12 @@ object_wait(j6_handle_t handle, j6_signal_t mask, j6_signal_t *sigs)
if (!obj)
return j6_err_invalid_arg;
j6_signal_t current = obj->signals();
if ((current & mask) != 0) {
*sigs = current;
return j6_status_ok;
}
obj->add_blocked_thread(th);
th->wait_on_signals(obj, mask);
s.schedule();
@@ -30,4 +37,22 @@ object_wait(j6_handle_t handle, j6_signal_t mask, j6_signal_t *sigs)
return result;
}
j6_status_t
object_signal(j6_handle_t handle, j6_signal_t signals)
{
if ((signals & j6_signal_user_mask) != signals)
return j6_err_invalid_arg;
scheduler &s = scheduler::get();
thread *th = thread::from_tcb(s.current());
process &p = th->parent();
kobject *obj = p.lookup_handle(handle);
if (!obj)
return j6_err_invalid_arg;
obj->assert_signal(signals);
return j6_status_ok;
}
} // namespace syscalls