From 51a3988ec0ea1de35e47a999a76c14df05737a34 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 16 Mar 2024 09:42:03 -0400 Subject: kernel: sched: Cleanup context switch comments Signed-off-by: Ian Moffett --- sys/kern/kern_sched.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sys/kern') 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); } -- cgit v1.2.3