summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/include/sys/sched.h1
-rw-r--r--sys/kern/kern_sched.c14
2 files changed, 15 insertions, 0 deletions
diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h
index f06c104..1fa947e 100644
--- a/sys/include/sys/sched.h
+++ b/sys/include/sys/sched.h
@@ -37,6 +37,7 @@
#include <machine/cpu.h>
#include <machine/frame.h>
+struct proc *this_td(void);
void sched_init(void);
void sched_exit(void);
void sched_context_switch(struct trapframe *tf);
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
@@ -322,6 +322,20 @@ sched_exit(void)
}
/*
+ * 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
*/
void