From a3e45d5dcaf1bf3a9e684b5fcc301413ec994a9b Mon Sep 17 00:00:00 2001 From: Kimplul Date: Wed, 9 Nov 2022 16:27:23 +0200 Subject: add basic IPI structure --- common/uapi/dispatch.c | 9 ++++++--- common/uapi/ipc.c | 44 +++++++++++++++----------------------------- 2 files changed, 21 insertions(+), 32 deletions(-) (limited to 'common/uapi') diff --git a/common/uapi/dispatch.c b/common/uapi/dispatch.c index 27cc001..2cf19fb 100644 --- a/common/uapi/dispatch.c +++ b/common/uapi/dispatch.c @@ -10,6 +10,8 @@ #include #include +#include + /** Syscall number to syscall handler conversion. */ static const sys_t syscall_table[] = { /* noop */ @@ -79,10 +81,11 @@ SYSCALL_DEFINE1(putch)(sys_arg_t a){ return SYS_RET1(OK); } -struct sys_ret syscall_dispatch(sys_arg_t syscall, sys_arg_t a, sys_arg_t b, - sys_arg_t c, sys_arg_t d, sys_arg_t e) +struct sys_ret handle_syscall(struct tcb *t, + sys_arg_t syscall, sys_arg_t a, sys_arg_t b, + sys_arg_t c, sys_arg_t d, sys_arg_t e) { - struct tcb *t = cur_tcb(); + adjust_syscall(t); size_t sc = syscall; if (sc >= ARRAY_SIZE(syscall_table)) { diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c index 34f707a..cb53ee3 100644 --- a/common/uapi/ipc.c +++ b/common/uapi/ipc.c @@ -8,6 +8,7 @@ #include #include +#include /** * IPC server notification syscall handler. @@ -114,36 +115,21 @@ SYSCALL_DEFINE4(ipc_resp)(sys_arg_t d0, sys_arg_t d1, sys_arg_t d2, * \todo Implement. * * @param tid Thread ID to notify. - * @param swap Whether to swap immediately if possible. * @return \ref OK and 0. */ -SYSCALL_DEFINE2(ipc_notify)(sys_arg_t tid, sys_arg_t swap){ - /** \todo masquerade as kernel call, set from to 0 and set us as - * notify type, no arguments as that would require too much state - * handling for my liking. Instead, a server and a client have to agree - * on some rpc API, and ipc_notify is just used to asynchronously inform - * the client that it should check the status of its async operations. - * Arguably slower than directly telling the client which operation was - * finished, but this would require the kernel to keep track of a notify - * stack. While not impossible, probably too complex. */ - - /* Something like - * - * struct tcb *t = get_tcb(tid); - * if (t->notify_state == NOTIFY_QUEUED) - * return; - * - * if (t->notify_state == NOTIFY_RUNNING) { - * t->notify = NOTIFY_QUEUED; - * return; - * } - * - * t->notify_state = NOTIFY_QUEUED; - * if (swap) - * do_swap(); // clears t->notify when swapped to - * // if already running in base state, interrupt, - * otherwise wait for return from rpc. If not running, - * just queue the interrupt. - */ +SYSCALL_DEFINE1(ipc_notify)(sys_arg_t tid){ + struct tcb *t = get_tcb(tid); + if (t->notify_state == NOTIFY_QUEUED) + return SYS_RET1(OK); + + if (t->notify_state == NOTIFY_RUNNING) { + t->notify_state = NOTIFY_QUEUED; + return SYS_RET1(OK); + } + + t->notify_state = NOTIFY_QUEUED; + if (running(t)) + send_ipi(t); + return SYS_RET1(OK); } -- cgit v1.3