From 44bbb86a75043b38bdfb9ed6ff4be0764e3fc905 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 13 Oct 2025 14:53:04 -0400 Subject: kern: proc: Implement process sleeping and waking Signed-off-by: Ian Moffett --- src/sys/include/sys/proc.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/sys/include') diff --git a/src/sys/include/sys/proc.h b/src/sys/include/sys/proc.h index 9f5cd73..bb34066 100644 --- a/src/sys/include/sys/proc.h +++ b/src/sys/include/sys/proc.h @@ -90,6 +90,7 @@ struct proc { struct filedesc *fdtab[FD_MAX]; struct penv_blk *envblk; struct ptrbox *envblk_box; + struct proc *parent; mac_level_t level; struct spinlock maplist_lock; sigtab_t sigtab; @@ -99,6 +100,7 @@ struct proc { }; #define PROC_EXITING BIT(0) /* Process is exiting */ +#define PROC_SLEEPING BIT(1) /* Process is sleeping */ /* * Initialize a process into a basic minimal @@ -203,6 +205,26 @@ int md_set_ip(struct proc *procp, uintptr_t ip); */ int proc_check_addr(struct proc *proc, uintptr_t addr, size_t len); +/* + * Put a process to sleep + * + * @proc: Process to put to sleep + * + * Returns zero if the address is within the process bounds, + * otherwise a less than zero value on failure. + */ +int proc_sleep(struct proc *proc); + +/* + * Wake up a process + * + * @proc: Process to wake up + * + * Returns zero if the address is within the process bounds, + * otherwise a less than zero value on failure. + */ +int proc_wake(struct proc *proc); + /* * Lookup a process using its PID * @@ -212,6 +234,12 @@ int proc_check_addr(struct proc *proc, uintptr_t addr, size_t len); */ struct proc *proc_lookup(pid_t pid); +/* + * Put the current process to sleep until woken + * up + */ +void md_proc_sleep(void); + /* * Put the current process into a halt loop * until the next one runs. -- cgit v1.2.3