From 1e7a1c0d90f6eb339e3e68c7b91bb21e81e06d5c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 15 Mar 2024 18:39:47 -0400 Subject: kernel: sched: Add routine to get current thread Signed-off-by: Ian Moffett --- sys/kern/kern_sched.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 117e0c1..d775e5a 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -321,6 +321,20 @@ sched_exit(void) sched_enter(); } +/* + * Get the current running thread. + */ +struct proc * +this_td(void) +{ + struct sched_state *state; + struct cpu_info *ci; + + ci = this_cpu(); + state = &ci->sched_state; + return state->td; +} + /* * Thread context switch routine */ -- cgit v1.2.3