summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-05-28 23:29:52 -0400
committerIan Moffett <ian@osmora.org>2025-05-28 23:29:52 -0400
commitcb807eb795e1380513db4c7dbce0452645746abf (patch)
tree0fbf05f3ee0bb54d6dfa3c93d0fb551343635a2e
parent7cc1c177de67a79ecdd428bebb8718692a6bff0d (diff)
kernel: proc: Store kernel thread flag in `proc'
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/arch/amd64/amd64/proc_machdep.c1
-rw-r--r--sys/include/sys/proc.h6
-rw-r--r--sys/kern/kern_exit.c6
3 files changed, 5 insertions, 8 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c
index 9579b7e..f6b91f9 100644
--- a/sys/arch/amd64/amd64/proc_machdep.c
+++ b/sys/arch/amd64/amd64/proc_machdep.c
@@ -201,6 +201,7 @@ md_spawn(struct proc *p, struct proc *parent, uintptr_t ip)
*/
if (rpl == 0) {
stack_base += VM_HIGHER_HALF;
+ p->flags |= PROC_KTD;
} else {
vm_map(pcbp->addrsp, stack_base, stack_base,
PROT_READ | PROT_WRITE | PROT_USER, PROC_STACK_PAGES);
diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h
index 7b03672..0a7d133 100644
--- a/sys/include/sys/proc.h
+++ b/sys/include/sys/proc.h
@@ -83,11 +83,7 @@ struct proc {
#define PROC_ZOMB BIT(2) /* Zombie (dead but not deallocated) */
#define PROC_LEAFQ BIT(3) /* Leaf queue is active */
#define PROC_WAITED BIT(4) /* Being waited on by parent */
-
-/*
- * Flags for exit1()
- */
-#define EXIT_KTD BIT(0) /* Kill a kernel thread */
+#define PROC_KTD BIT(5) /* Kernel thread */
struct proc *this_td(void);
struct proc *get_child(struct proc *cur, pid_t pid);
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 39fa96d..242b221 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -41,7 +41,7 @@
#define pr_error(...) pr_trace(__VA_ARGS__)
static void
-unload_td(struct proc *td, int flags)
+unload_td(struct proc *td)
{
const struct auxval *auxvalp;
struct exec_prog *execp;
@@ -50,7 +50,7 @@ unload_td(struct proc *td, int flags)
size_t len;
sched_detach(td);
- if (ISSET(flags, EXIT_KTD)) {
+ if (ISSET(td->flags, PROC_KTD)) {
return;
}
@@ -117,7 +117,7 @@ exit1(struct proc *td, int flags)
stack -= VM_HIGHER_HALF;
}
- unload_td(td, flags);
+ unload_td(td);
vm_unmap(pcbp->addrsp, td->stack_base, PROC_STACK_SIZE);
vm_free_frame(stack, PROC_STACK_PAGES);
pmap_destroy_vas(pcbp->addrsp);