aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-07-02 21:41:29 -0400
committerIan Moffett <ian@osmora.org>2024-07-02 21:41:29 -0400
commit531f6f7b00821867bb4941b05bcbeea9f0357557 (patch)
tree657ca5b1a6ec0ed25e4d360a6cd5c3ddf9ae0d55
parent2d7bc823503167276c6d3c40500c3055d4f38938 (diff)
kernel: proc: Remove PROC_INEXEC flag
This commit removes handling of the PROC_INEXEC flag as md_td_kick() takes care of the transfer to user mode in a cleaner way. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/include/sys/proc.h1
-rw-r--r--sys/kern/kern_exec.c11
-rw-r--r--sys/kern/kern_sched.c16
3 files changed, 3 insertions, 25 deletions
diff --git a/sys/include/sys/proc.h b/sys/include/sys/proc.h
index 805c4a5..ceeb5e4 100644
--- a/sys/include/sys/proc.h
+++ b/sys/include/sys/proc.h
@@ -58,7 +58,6 @@ struct proc {
#define PROC_EXITING BIT(0) /* Exiting */
#define PROC_EXEC BIT(1) /* Exec called (cleared by sched) */
-#define PROC_INEXEC BIT(2) /* Exec in progress */
struct proc *this_td(void);
int md_fork(struct proc *p, struct proc *parent, uintptr_t ip);
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 7825448..1466159 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -71,7 +71,7 @@ execve(struct proc *td, const struct execve_args *args)
return error;
/* Mark the thread as running exec */
- td->flags |= (PROC_EXEC | PROC_INEXEC);
+ td->flags |= PROC_EXEC;
/* Create the new stack */
stack = vm_alloc_frame(PROC_STACK_PAGES);
@@ -97,12 +97,7 @@ execve(struct proc *td, const struct execve_args *args)
md_td_stackinit(td, (void *)(stack_top + VM_HIGHER_HALF), &prog);
setregs(td, &prog, stack_top);
- /*
- * Done, reset flags and start the user thread.
- *
- * XXX: PROC_EXEC is unset by the scheduler so it
- * can properly start the new exec'd program.
- */
- td->flags &= ~PROC_INEXEC;
+ /* Done, reset flags and start the user thread */
+ td->flags &= ~PROC_EXEC;
md_td_kick(td);
}
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 278eba2..1d79937 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -150,26 +150,10 @@ sched_switch(struct trapframe *tf)
struct pcb *pcbp;
struct proc *next_td, *td;
bool use_current = true;
- bool inexec;
ci = this_cpu();
td = ci->curtd;
- if (td != NULL) {
- inexec = ISSET(td->flags, PROC_INEXEC);
-
- /*
- * If both PROC_INEXEC and PROC_EXEC are set,
- * an exec is in progress. However, if PROC_INEXEC is
- * unset and PROC_EXEC is set, an exec has completed
- * and we can unset PROC_EXEC and copy the new trapframe.
- */
- if (ISSET(td->flags, PROC_EXEC) && !inexec) {
- memcpy(tf, &td->tf, sizeof(*tf));
- td->flags &= ~PROC_EXEC;
- }
- }
-
/*
* Get the next thread and use it only if it isn't
* in the middle of an exit, exec, or whatever.