From 810b5c49ebfb3398a8d9a89dedba6b97cb8688b1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 15 Oct 2025 19:02:52 -0400 Subject: kern/amd64: Introduce kernel threads Introduces kernel threads. by using the proc_ktd() function, one can spawn a CPL 0 running thread to the desired code. Signed-off-by: Ian Moffett --- src/sys/include/sys/proc.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/sys/include') diff --git a/src/sys/include/sys/proc.h b/src/sys/include/sys/proc.h index 618ddf3..f23c0b0 100644 --- a/src/sys/include/sys/proc.h +++ b/src/sys/include/sys/proc.h @@ -101,6 +101,10 @@ struct proc { #define PROC_EXITING BIT(0) /* Process is exiting */ #define PROC_SLEEPING BIT(1) /* Process is sleeping */ +#define PROC_KTD BIT(2) /* Process is kernel thread */ + +/* Flags for PROC_SPAWN */ +#define SPAWN_KTD BIT(0) /* Spawn kernel thread */ /* * Initialize a process into a basic minimal @@ -135,6 +139,14 @@ struct proc *proc_self(void); */ int proc_add_range(struct proc *procp, vaddr_t va, paddr_t pa, size_t len); +/* + * Spawn a kernel thread + * + * @procp_res: Result is written here + * @fn: Function where kernel thread should end up + */ +int proc_ktd(struct proc **procp_res, void(*fn)(void *)); + /* * Kill a process with a specific status code * -- cgit v1.2.3