summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-20 00:47:13 -0400
committerIan Moffett <ian@osmora.org>2025-08-20 00:47:13 -0400
commit2db57d095d2be9973c89fb97b72047d353fb4ad3 (patch)
tree889a0e5573b56ab6152c13aa6d08e7d1f16cf87b /sys/arch/amd64
parent188297a70053a59fddcca7dc598ae4adfaef4199 (diff)
kernel: Allow preemption to be enabled/disabled
Introduce sched_preempt_set() which can be useful to implement priority inheritance for preventing priority inversion Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/amd64/proc_machdep.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c
index 56348be..11b1901 100644
--- a/sys/arch/amd64/amd64/proc_machdep.c
+++ b/sys/arch/amd64/amd64/proc_machdep.c
@@ -264,6 +264,24 @@ sched_switch_to(struct trapframe *tf, struct proc *td)
}
/*
+ * Enable or disable preemption on the current
+ * processor
+ *
+ * @enable: Enable preemption if true
+ */
+void
+sched_preempt_set(bool enable)
+{
+ struct cpu_info *ci = this_cpu();
+
+ if (ci == NULL) {
+ return;
+ }
+
+ ci->preempt = enable;
+}
+
+/*
* Perform a context switch.
*/
void