diff options
| -rw-r--r-- | common/uapi/ipc.c | 21 | ||||
| -rw-r--r-- | include/apos/tcb.h | 17 |
2 files changed, 36 insertions, 2 deletions
diff --git a/common/uapi/ipc.c b/common/uapi/ipc.c index 141b494..826fd57 100644 --- a/common/uapi/ipc.c +++ b/common/uapi/ipc.c @@ -95,5 +95,24 @@ SYSCALL_DEFINE2(ipc_notify)(sys_arg_t tid, sys_arg_t swap){ * 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. */ - return (struct sys_ret){ OK, 0, 0 /* type */, 0 /* from */, 0, 0 }; + + /* 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. + */ + return (struct sys_ret){ OK, 0, 0 /* type */, 0, 0, 0 }; } diff --git a/include/apos/tcb.h b/include/apos/tcb.h index 41b5237..72dcc98 100644 --- a/include/apos/tcb.h +++ b/include/apos/tcb.h @@ -49,7 +49,7 @@ /* forward declaration */ struct tcb; -/** Convenience structure for \see tcb. */ +/** Convenience structure for \ref tcb. */ struct tcb_ctx { /** Virtual address space of context. */ struct vmem *vmem; @@ -61,6 +61,18 @@ struct tcb_ctx { struct tcb *prev; }; +/** Enum for notification states. */ +enum tcb_notify_state { + /** Thread has notifcations queued. */ + NOTIFY_QUEUED, + + /** Thread is running notification handler. */ + NOTIFY_RUNNING, + + /** Thread is free to be notified. */ + NOTIFY_WAITING +}; + /** Thread control block. Main way to handle threads. */ struct tcb { /** Arch-specific data. */ @@ -128,6 +140,9 @@ struct tcb { /** RPC context of thread. */ struct tcb_ctx rpc; + + /** Notifcation state of thread. */ + enum tcb_notify notify_state; }; /** |
