aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-16 09:42:03 -0400
committerIan Moffett <ian@osmora.org>2024-03-16 09:44:19 -0400
commit51a3988ec0ea1de35e47a999a76c14df05737a34 (patch)
tree081cd1aeae25b049882c636aee1be5cb5ea61fe1 /sys/kern
parent3408aee1a98e86a80b941371cc3095974a7a1ec2 (diff)
kernel: sched: Cleanup context switch comments
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_sched.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 77aab54..7b3776d 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -360,18 +360,23 @@ sched_context_switch(struct trapframe *tf)
return;
}
+ /*
+ * If we have a thread currently running and we are switching
+ * to another, we shall save our current register state
+ * by copying the trapframe.
+ */
if (state->td != NULL) {
- /* Save our trapframe */
td = state->td;
memcpy(td->tf, tf, sizeof(struct trapframe));
}
- /* Copy to stack */
+ /* Copy over the next thread's register state to us */
memcpy(tf, next_td->tf, sizeof(struct trapframe));
td = state->td;
state->td = next_td;
+ /* Re-enqueue the previous thread if it exists */
if (td != NULL) {
sched_enqueue_td(td);
}