aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-12-21 12:41:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2017-12-21 12:54:33 -0500
commitd303e556add161a8a1cc64a981383ecd3a8a6896 (patch)
tree226adc337c8fb6ce494be3e16f69de07e850335b /src
parent1d21bf66c605d114055e50d715e2dcbe2ddfd86a (diff)
downloadkutter-d303e556add161a8a1cc64a981383ecd3a8a6896.tar.gz
kutter-d303e556add161a8a1cc64a981383ecd3a8a6896.tar.xz
kutter-d303e556add161a8a1cc64a981383ecd3a8a6896.zip
sched: Interrupts must be disabled during setjmp() call
On the AVR platform (and possibly others) the longjmp() call will restore the interrupt state saved during the setjmp() call. So, the setjmp() call must be invoked with interrupts disabled to ensure that shutdown handling is run with interrupts disabled. This fixes potential corruption of the shutdown processing on AVR. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/sched.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/sched.c b/src/sched.c
index f278c426..248d3c68 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -282,6 +282,7 @@ sched_clear_shutdown(void)
static void
run_shutdown(int reason)
{
+ irq_disable();
uint32_t cur = timer_read_time();
if (!shutdown_status)
shutdown_reason = reason;
@@ -334,9 +335,11 @@ sched_main(void)
sendf("starting");
+ irq_disable();
int ret = setjmp(shutdown_jmp);
if (ret)
run_shutdown(ret);
+ irq_enable();
run_tasks();
}