From 2db57d095d2be9973c89fb97b72047d353fb4ad3 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 20 Aug 2025 00:47:13 -0400 Subject: 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 --- sys/arch/amd64/amd64/proc_machdep.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sys/arch/amd64') 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 @@ -263,6 +263,24 @@ sched_switch_to(struct trapframe *tf, struct proc *td) pmap_switch_vas(pcbp->addrsp); } +/* + * 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. */ -- cgit v1.2.3