mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-10-06 06:59:08 +08:00
Added the missing memory barrier so ARMv7-A SMP schedulers no longer miss preemptions (#704)
_tx_thread_schedule stores the newly selected thread into _tx_thread_current_ptr[core] and then reloads _tx_thread_execute_ptr[core] to detect a concurrent scheduling decision made by another core. On the other side, _tx_thread_smp_core_interrupt stores the execute pointer and then reads the current pointer to decide whether an inter-core interrupt is required. This is a store-buffer pattern: without a barrier both cores can observe stale values, the interrupt is skipped, and a ready thread with the highest priority is never scheduled. The barrier was added to the ARMv8-A SMP scheduler in 6.2.1, but the ARMv7-A SMP ports were left untouched even though they implement the same protocol. This adds the corresponding DMB to the Cortex-A5, Cortex-A7 and Cortex-A9 SMP schedulers for both the AC5 and GNU toolchains. The GNU variants were verified by assembling them with arm-none-eabi-gcc 13.2.1 for their respective cores. Refs #209 Assisted-by: Copilot (Opus 5) <noreply@github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
; Some portions generated by Copilot (Opus 5).
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
@@ -164,6 +167,7 @@ _tx_thread_ready_for_execution
|
||||
LDR r2, =_tx_thread_current_ptr ; Pickup address of current thread
|
||||
ADD r2, r2, r12 ; Build index into the current thread array
|
||||
STR r0, [r2, #0] ; Setup current thread pointer
|
||||
DMB ; Ensure the current thread pointer write completes
|
||||
;
|
||||
; /* In the time between reading the execute pointer and assigning
|
||||
; it to the current pointer, the execute pointer was changed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@/***************************************************************************
|
||||
@ * Copyright (c) 2024 Microsoft Corporation
|
||||
@ * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
@ *
|
||||
@ * This program and the accompanying materials are made available under the
|
||||
@ * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
@ * SPDX-License-Identifier: MIT
|
||||
@ **************************************************************************/
|
||||
@
|
||||
@ Some portions generated by Copilot (Opus 5).
|
||||
@
|
||||
@
|
||||
@/**************************************************************************/
|
||||
@/**************************************************************************/
|
||||
@@ -166,6 +169,7 @@ _tx_thread_ready_for_execution:
|
||||
LDR r2, =_tx_thread_current_ptr @ Pickup address of current thread
|
||||
ADD r2, r2, r12 @ Build index into the current thread array
|
||||
STR r0, [r2, #0] @ Setup current thread pointer
|
||||
DMB @ Ensure the current thread pointer write completes
|
||||
@
|
||||
@ /* In the time between reading the execute pointer and assigning
|
||||
@ it to the current pointer, the execute pointer was changed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
; Some portions generated by Copilot (Opus 5).
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
@@ -163,6 +166,7 @@ _tx_thread_ready_for_execution
|
||||
LDR r2, =_tx_thread_current_ptr ; Pickup address of current thread
|
||||
ADD r2, r2, r12 ; Build index into the current thread array
|
||||
STR r0, [r2, #0] ; Setup current thread pointer
|
||||
DMB ; Ensure the current thread pointer write completes
|
||||
;
|
||||
; /* In the time between reading the execute pointer and assigning
|
||||
; it to the current pointer, the execute pointer was changed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@/***************************************************************************
|
||||
@ * Copyright (c) 2024 Microsoft Corporation
|
||||
@ * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
@ *
|
||||
@ * This program and the accompanying materials are made available under the
|
||||
@ * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
@ * SPDX-License-Identifier: MIT
|
||||
@ **************************************************************************/
|
||||
@
|
||||
@ Some portions generated by Copilot (Opus 5).
|
||||
@
|
||||
@
|
||||
@/**************************************************************************/
|
||||
@/**************************************************************************/
|
||||
@@ -180,6 +183,7 @@ _tx_thread_ready_for_execution:
|
||||
LDR r2, =_tx_thread_current_ptr @ Pickup address of current thread
|
||||
ADD r2, r2, r12 @ Build index into the current thread array
|
||||
STR r0, [r2, #0] @ Setup current thread pointer
|
||||
DMB @ Ensure the current thread pointer write completes
|
||||
@
|
||||
@ /* In the time between reading the execute pointer and assigning
|
||||
@ it to the current pointer, the execute pointer was changed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
;/***************************************************************************
|
||||
; * Copyright (c) 2024 Microsoft Corporation
|
||||
; * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
; *
|
||||
; * This program and the accompanying materials are made available under the
|
||||
; * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
; * SPDX-License-Identifier: MIT
|
||||
; **************************************************************************/
|
||||
;
|
||||
; Some portions generated by Copilot (Opus 5).
|
||||
;
|
||||
;
|
||||
;/**************************************************************************/
|
||||
;/**************************************************************************/
|
||||
@@ -163,6 +166,7 @@ _tx_thread_ready_for_execution
|
||||
LDR r2, =_tx_thread_current_ptr ; Pickup address of current thread
|
||||
ADD r2, r2, r12 ; Build index into the current thread array
|
||||
STR r0, [r2, #0] ; Setup current thread pointer
|
||||
DMB ; Ensure the current thread pointer write completes
|
||||
;
|
||||
; /* In the time between reading the execute pointer and assigning
|
||||
; it to the current pointer, the execute pointer was changed by
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@/***************************************************************************
|
||||
@ * Copyright (c) 2024 Microsoft Corporation
|
||||
@ * Copyright (c) 2026 Eclipse ThreadX contributors
|
||||
@ *
|
||||
@ * This program and the accompanying materials are made available under the
|
||||
@ * terms of the MIT License which is available at
|
||||
@@ -8,6 +9,8 @@
|
||||
@ * SPDX-License-Identifier: MIT
|
||||
@ **************************************************************************/
|
||||
@
|
||||
@ Some portions generated by Copilot (Opus 5).
|
||||
@
|
||||
@
|
||||
@/**************************************************************************/
|
||||
@/**************************************************************************/
|
||||
@@ -165,6 +168,7 @@ _tx_thread_ready_for_execution:
|
||||
LDR r2, =_tx_thread_current_ptr @ Pickup address of current thread
|
||||
ADD r2, r2, r12 @ Build index into the current thread array
|
||||
STR r0, [r2, #0] @ Setup current thread pointer
|
||||
DMB @ Ensure the current thread pointer write completes
|
||||
@
|
||||
@ /* In the time between reading the execute pointer and assigning
|
||||
@ it to the current pointer, the execute pointer was changed by
|
||||
|
||||
Reference in New Issue
Block a user