From 4d961dd993c99958874441e9389ab408efa55e0d Mon Sep 17 00:00:00 2001
From: Armin Luntzer <armin.luntzer@univie.ac.at>
Date: Wed, 13 Jun 2018 13:11:11 +0200
Subject: [PATCH] add CONFIG_DISABLE_TASK_PREEMPTION

---
 arch/sparc/kernel/irqtrap.S |  2 ++
 kernel/Kconfig              | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/sparc/kernel/irqtrap.S b/arch/sparc/kernel/irqtrap.S
index 8d1e0a9..b1bb5d8 100644
--- a/arch/sparc/kernel/irqtrap.S
+++ b/arch/sparc/kernel/irqtrap.S
@@ -51,8 +51,10 @@ __interrupt_entry:
 #else /* CONFIG_SPARC_NESTED_IRQ */
 	 or %t_psr, PSR_PIL, %t_tmp
 
+#ifndef CONFIG_TASK_PREEMPTION_DISABLE
 	call schedule
 	 nop
+#endif
 	wr	%t_tmp, PSR_ET, %psr	! we can't be preemted here, so set PIL
 					! to max and xor ET to enable
 					! delayed-write; nops not needed if
diff --git a/kernel/Kconfig b/kernel/Kconfig
index eb60f3c..51bf1e7 100644
--- a/kernel/Kconfig
+++ b/kernel/Kconfig
@@ -26,6 +26,19 @@ config IRQ_STATS_COLLECT
 	 Collect interrupt statistics and expose them in the
 	 systl tree.
 
+config TASK_PREEMPTION_DISABLE
+	bool "Disable forced preemption of tasks"
+	default n
+	help
+	 Say Y here to change the task system to be collaborative, i.e.
+	 for voluntary yields and run-to-completion. Note that this does not
+	 mean that tasks can not be preempted at all, just that there will
+	 be no supervisor to instigate such an event. Any IRQs will still
+	 preempt a running task, as will blocked I/O and locking operations.
+	 The latter may result in a rescheduling events to prevent priority
+	 inversion etc.
+	 WARNING: Currently unstable. Use for development only. You have been warned.
+
 config SOC
 	bool "Enable System-On-Chip configurations"
 	default n
-- 
GitLab