mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-10-06 06:59:08 +08:00
Fixed SMP execution profile total getters (#553)
Updated the SMP execution profile aggregate getters to copy each core's total into the matching output array element. Added a focused regression test for thread, ISR, and idle total getters. Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
co-authored by
Codex
parent
859c098747
commit
b880ffeada
@@ -162,3 +162,19 @@ foreach(test_case ${regression_test_cases})
|
||||
target_link_libraries(${test_name} PRIVATE azrtos::threadx_smp)
|
||||
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
|
||||
endforeach()
|
||||
|
||||
add_executable(threadx_smp_execution_profile_get_test
|
||||
${SOURCE_DIR}/threadx_smp_execution_profile_get_test.c
|
||||
${REPO_ROOT}/utility/execution_profile_kit/smp_version/tx_execution_profile.c)
|
||||
target_include_directories(threadx_smp_execution_profile_get_test
|
||||
PRIVATE
|
||||
${SOURCE_DIR}/execution_profile_test
|
||||
${REPO_ROOT}/utility/execution_profile_kit/smp_version)
|
||||
target_compile_definitions(threadx_smp_execution_profile_get_test
|
||||
PRIVATE CTEST BATCH_TEST TEST_STACK_SIZE_PRINTF=4096)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(threadx_smp_execution_profile_get_test PRIVATE -m64)
|
||||
target_link_options(threadx_smp_execution_profile_get_test PRIVATE -m64)
|
||||
endif()
|
||||
add_test(${CMAKE_BUILD_TYPE}::threadx_smp_execution_profile_get_test
|
||||
threadx_smp_execution_profile_get_test)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/***************************************************************************
|
||||
* 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
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* AI Disclosure: This file was largely AI-generated by Codex (GPT-5).
|
||||
* The AI-generated portions may be considered public domain (CC0-1.0)
|
||||
* and not subject to the project's licence. The human contributor has
|
||||
* reviewed and verified that the code is correct.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT and CC0-1.0
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef TX_API_H
|
||||
#define TX_API_H
|
||||
|
||||
#define TX_THREAD_SMP_MAX_CORES 4U
|
||||
#define TX_SUCCESS 0U
|
||||
#define TX_NOT_DONE 20U
|
||||
#define TX_NULL ((void *) 0)
|
||||
#define TX_SMP_CORE_ID 0U
|
||||
|
||||
typedef unsigned int UINT;
|
||||
typedef unsigned long ULONG;
|
||||
typedef void VOID;
|
||||
|
||||
typedef struct TX_THREAD_STRUCT
|
||||
{
|
||||
unsigned long long tx_thread_execution_time_total;
|
||||
unsigned long tx_thread_execution_time_last_start;
|
||||
struct TX_THREAD_STRUCT *tx_thread_created_next;
|
||||
} TX_THREAD;
|
||||
|
||||
#define TX_INTERRUPT_SAVE_AREA
|
||||
#define TX_DISABLE
|
||||
#define TX_RESTORE
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
/***************************************************************************
|
||||
* 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
|
||||
* https://opensource.org/licenses/MIT.
|
||||
*
|
||||
* AI Disclosure: This file was largely AI-generated by Codex (GPT-5).
|
||||
* The AI-generated portions may be considered public domain (CC0-1.0)
|
||||
* and not subject to the project's licence. The human contributor has
|
||||
* reviewed and verified that the code is correct.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT and CC0-1.0
|
||||
**************************************************************************/
|
||||
|
||||
/* This test verifies that the SMP execution profile aggregate getters copy every core value. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
#include "tx_execution_profile.h"
|
||||
|
||||
extern EXECUTION_TIME _tx_execution_thread_time_total[TX_THREAD_SMP_MAX_CORES];
|
||||
extern EXECUTION_TIME _tx_execution_isr_time_total[TX_THREAD_SMP_MAX_CORES];
|
||||
extern EXECUTION_TIME _tx_execution_idle_time_total[TX_THREAD_SMP_MAX_CORES];
|
||||
|
||||
ULONG _tx_thread_system_state[TX_THREAD_SMP_MAX_CORES];
|
||||
UINT _tx_thread_preempt_disable;
|
||||
TX_THREAD *_tx_thread_current_ptr[TX_THREAD_SMP_MAX_CORES];
|
||||
TX_THREAD *_tx_thread_execute_ptr[TX_THREAD_SMP_MAX_CORES];
|
||||
TX_THREAD *_tx_thread_created_ptr;
|
||||
ULONG _tx_thread_created_count;
|
||||
|
||||
|
||||
ULONG _tx_thread_smp_time_get(void)
|
||||
{
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
static UINT verify_time_values(EXECUTION_TIME *actual, EXECUTION_TIME *expected)
|
||||
{
|
||||
|
||||
UINT core;
|
||||
|
||||
|
||||
for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++)
|
||||
{
|
||||
|
||||
if (actual[core] != expected[core])
|
||||
{
|
||||
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
EXECUTION_TIME thread_time[TX_THREAD_SMP_MAX_CORES];
|
||||
EXECUTION_TIME isr_time[TX_THREAD_SMP_MAX_CORES];
|
||||
EXECUTION_TIME idle_time[TX_THREAD_SMP_MAX_CORES];
|
||||
EXECUTION_TIME expected_thread_time[TX_THREAD_SMP_MAX_CORES];
|
||||
EXECUTION_TIME expected_isr_time[TX_THREAD_SMP_MAX_CORES];
|
||||
EXECUTION_TIME expected_idle_time[TX_THREAD_SMP_MAX_CORES];
|
||||
UINT core;
|
||||
UINT status;
|
||||
|
||||
|
||||
printf("Running SMP Execution Profile Get Test............................... ");
|
||||
|
||||
for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++)
|
||||
{
|
||||
|
||||
expected_thread_time[core] = ((EXECUTION_TIME) 1000U) + ((EXECUTION_TIME) core);
|
||||
expected_isr_time[core] = ((EXECUTION_TIME) 2000U) + ((EXECUTION_TIME) core);
|
||||
expected_idle_time[core] = ((EXECUTION_TIME) 3000U) + ((EXECUTION_TIME) core);
|
||||
|
||||
_tx_execution_thread_time_total[core] = expected_thread_time[core];
|
||||
_tx_execution_isr_time_total[core] = expected_isr_time[core];
|
||||
_tx_execution_idle_time_total[core] = expected_idle_time[core];
|
||||
|
||||
thread_time[core] = 0xFFFFFFFFFFFFFFFFULL;
|
||||
isr_time[core] = 0xFFFFFFFFFFFFFFFFULL;
|
||||
idle_time[core] = 0xFFFFFFFFFFFFFFFFULL;
|
||||
}
|
||||
|
||||
status = _tx_execution_thread_total_time_get(thread_time);
|
||||
status += _tx_execution_isr_time_get(isr_time);
|
||||
status += _tx_execution_idle_time_get(idle_time);
|
||||
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("ERROR #1\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (verify_time_values(thread_time, expected_thread_time) != 0U)
|
||||
{
|
||||
|
||||
printf("ERROR #2\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (verify_time_values(isr_time, expected_isr_time) != 0U)
|
||||
{
|
||||
|
||||
printf("ERROR #3\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (verify_time_values(idle_time, expected_idle_time) != 0U)
|
||||
{
|
||||
|
||||
printf("ERROR #4\n");
|
||||
return(1);
|
||||
}
|
||||
|
||||
printf("SUCCESS!\n");
|
||||
return(0);
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
**************************************************************************/
|
||||
|
||||
// Some portions generated by Codex (GPT-5).
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
@@ -962,7 +963,7 @@ UINT core;
|
||||
for (core = 0; core < TX_THREAD_SMP_MAX_CORES; core++)
|
||||
{
|
||||
|
||||
*total_time = _tx_execution_thread_time_total[core];
|
||||
total_time[core] = _tx_execution_thread_time_total[core];
|
||||
}
|
||||
|
||||
/* Restore interrupts. */
|
||||
@@ -1025,7 +1026,7 @@ UINT core;
|
||||
{
|
||||
|
||||
/* Return the total time. */
|
||||
*total_time = _tx_execution_isr_time_total[core];
|
||||
total_time[core] = _tx_execution_isr_time_total[core];
|
||||
}
|
||||
|
||||
/* Restore interrupts. */
|
||||
@@ -1088,7 +1089,7 @@ UINT core;
|
||||
{
|
||||
|
||||
/* Return the total time. */
|
||||
*total_time = _tx_execution_idle_time_total[core];
|
||||
total_time[core] = _tx_execution_idle_time_total[core];
|
||||
}
|
||||
|
||||
/* Restore interrupts. */
|
||||
|
||||
Reference in New Issue
Block a user