[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

@@ -60,6 +60,9 @@ public:
/// \arg s The set of signals to check
inline bool check_signal(j6_signal_t s) const { return (m_signals & s) == s; }
/// Get the current object signal state
inline j6_signal_t signals() const { return m_signals; }
/// Increment the handle refcount
inline void handle_retain() { ++m_handle_count; }

View File

@@ -2,6 +2,7 @@ SYSCALL(0x00, system_log, const char *)
SYSCALL(0x01, system_noop, void)
SYSCALL(0x09, object_wait, j6_handle_t, j6_signal_t, j6_signal_t *)
SYSCALL(0x0a, object_signal, j6_handle_t, j6_signal_t)
SYSCALL(0x10, process_koid, j6_koid_t *)
SYSCALL(0x11, process_exit, int64_t)

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