From 67e4ccbc516121b7f03077d2c61385d7ea65a44b Mon Sep 17 00:00:00 2001 From: Carlo Caione Date: Fri, 20 Mar 2020 12:03:45 +0100 Subject: [PATCH] arch: aarch64: Add check on context switch Check whether we actually need to schedule a new thread before calling the context switch routine. Signed-off-by: Carlo Caione --- arch/arm/core/aarch64/swap_helper.S | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/core/aarch64/swap_helper.S b/arch/arm/core/aarch64/swap_helper.S index bb8799899df..9956d14c1c5 100644 --- a/arch/arm/core/aarch64/swap_helper.S +++ b/arch/arm/core/aarch64/swap_helper.S @@ -209,6 +209,14 @@ offload: b inv context_switch: + /* Check if we need to context switch */ + ldr x1, =_kernel + ldr x2, [x1, #_kernel_offset_to_current] + ldr x3, [x1, #_kernel_offset_to_ready_q_cache] + cmp x2, x3 + beq exit + + /* Switch thread */ bl z_arm64_context_switch exit: