From 5e096e01c915f27a6c4ffdab10c39c899e88e315 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 9 May 2021 11:16:09 +0200 Subject: [PATCH] Context switch only on irq tail --- os/common/ports/RISCV-ECLIC/chcore.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/os/common/ports/RISCV-ECLIC/chcore.h b/os/common/ports/RISCV-ECLIC/chcore.h index 83d982ab..dd87d01f 100644 --- a/os/common/ports/RISCV-ECLIC/chcore.h +++ b/os/common/ports/RISCV-ECLIC/chcore.h @@ -287,7 +287,10 @@ struct port_context { * @details This macro must be inserted at the end of all IRQ handlers * enabled to invoke system APIs. */ -#define PORT_IRQ_EPILOGUE() return chSchIsPreemptionRequired(); +#define PORT_IRQ_EPILOGUE() port_lock_from_isr(); \ + bool is_preemption_required = ((__RV_CSR_READ(CSR_MSUBM) & MSUBM_PTYP) == 0) && chSchIsPreemptionRequired(); \ + port_unlock_from_isr(); \ + return is_preemption_required; /** * @brief IRQ handler function declaration.