From 97f727349beea290afa9bb194384711e383cc7d0 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 27 Nov 2019 01:39:33 +0100 Subject: [PATCH] cpu/atmega_common: Fixed atmega_exit_isr A context switch at the end of the ISR should only occur, if requested. This fixes this. --- cpu/atmega_common/thread_arch.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpu/atmega_common/thread_arch.c b/cpu/atmega_common/thread_arch.c index 4eb95a37f1..f80377f16a 100644 --- a/cpu/atmega_common/thread_arch.c +++ b/cpu/atmega_common/thread_arch.c @@ -248,11 +248,12 @@ void thread_yield_higher(void) void atmega_exit_isr(void) { atmega_in_isr = 0; - atmega_context_save(); - sched_run(); - atmega_context_restore(); - - __asm__ volatile ("reti"); + if (sched_context_switch_request) { + atmega_context_save(); + sched_run(); + atmega_context_restore(); + __asm__ volatile ("reti"); + } } __attribute__((always_inline)) static inline void atmega_context_save(void)