From 80dab4113523088be210b8c1f68b1bd4136a4744 Mon Sep 17 00:00:00 2001 From: Greg Link Date: Thu, 9 Jan 2025 11:00:09 -0500 Subject: [PATCH] Two basic structures for consideration This is not a mergeable commit, as it includes modifications to things that should not be committed upstream. --- CMakeLists.txt | 5 +- common/CMakeLists.txt | 1 + common/inc/tx_api.h | 23 +- common/src/tx_thread_resume.c | 95 ++--- common/src/tx_thread_suspend.c | 4 + .../src/tx_thread_suspend_resume_extension.c | 34 ++ common/src/tx_thread_system_resume.c | 12 + common/src/tx_thread_system_suspend.c | 6 + custom_tx_user.h | 335 ++++++++++++++++++ 9 files changed, 466 insertions(+), 49 deletions(-) create mode 100644 common/src/tx_thread_suspend_resume_extension.c create mode 100644 custom_tx_user.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 05baf6c7b..f7f4e94ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,9 @@ target_sources(freertos-threadx ) target_link_libraries(freertos-threadx PUBLIC threadx) + +set(TX_USER_FILE "${CMAKE_CURRENT_LIST_DIR}/custom_tx_user.h" CACHE PATH "Path to custom tx_user.h") + # If the user provided an override, copy it to the custom directory if (NOT TX_USER_FILE) message(STATUS "Using default tx_user.h file") @@ -55,7 +58,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${CUSTOM_INC_DIR} ) -target_compile_definitions(${PROJECT_NAME} PUBLIC "TX_INCLUDE_USER_DEFINE_FILE" ) +target_compile_definitions(${PROJECT_NAME} PUBLIC "TX_INCLUDE_USER_DEFINE_FILE" "TX_ENABLE_THREAD_SYSTEM_RESUME_EXTENSION") # Enable a build target that produces a ZIP file of all sources set(CPACK_SOURCE_GENERATOR "ZIP") diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 715e64c75..9338d42a4 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -101,6 +101,7 @@ target_sources(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_handler.c ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_error_notify.c ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_suspend.c + ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_suspend_resume_extension.c ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_preempt_check.c ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_resume.c ${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_suspend.c diff --git a/common/inc/tx_api.h b/common/inc/tx_api.h index dbf0d3460..641127c58 100644 --- a/common/inc/tx_api.h +++ b/common/inc/tx_api.h @@ -25,7 +25,7 @@ /* APPLICATION INTERFACE DEFINITION RELEASE */ /* */ /* tx_api.h PORTABLE C */ -/* 6.4.1 */ +/* 6.4.2 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ @@ -106,7 +106,10 @@ /* 03-01-2024 Tiejun Zhou Modified comment(s), */ /* update version number, */ /* resulting in version 6.4.1 */ -/* */ +/* XX-XX-2025 Greg Link Modified comment(s), */ +/* update version number, */ +/* add resume/suspend hooks, */ +/* resulting in version 6.4.2 */ /**************************************************************************/ #ifndef TX_API_H @@ -1779,6 +1782,22 @@ UINT _tx_thread_terminate(TX_THREAD *thread_ptr); UINT _tx_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice); UINT _tx_thread_wait_abort(TX_THREAD *thread_ptr); +/* Two alternative ways to include the proposed extensions of Issue 426. + The first expects the extension to always have the same function prototype, + but it is a proper function, while the second uses a #define in tx_user.h + to extend the functionality instead. */ + +#ifdef TX_ENABLE_THREAD_SYSTEM_RESUME_EXTENSION +UINT _tx_thread_system_resume_extension(TX_THREAD *thread_ptr); +#define TX_THREAD_SYSTEM_RESUME_EXTENSION(a) _tx_thread_system_resume_extension(a) +#else +#warning TX_ENABLE_THREAD_SYSTEM_RESUME_EXTENSION is disabled +#define TX_THREAD_SYSTEM_RESUME_EXTENSION(a) ((void)(a)) +#endif + +#ifndef TX_THREAD_SYSTEM_SUSPEND_EXTENSION +#define TX_THREAD_SYSTEM_SUSPEND_EXTENSION(a) ((void)(a)) +#endif /* Define error checking shells for API services. These are only referenced by the application. */ diff --git a/common/src/tx_thread_resume.c b/common/src/tx_thread_resume.c index b97bdb4b7..a725aa25c 100644 --- a/common/src/tx_thread_resume.c +++ b/common/src/tx_thread_resume.c @@ -81,29 +81,29 @@ TX_THREAD *saved_thread_ptr; UINT saved_threshold = ((UINT) 0); #ifdef TX_INLINE_THREAD_RESUME_SUSPEND -UINT priority; -ULONG priority_bit; -TX_THREAD *head_ptr; -TX_THREAD *tail_ptr; -TX_THREAD *execute_ptr; -TX_THREAD *current_thread; -ULONG combined_flags; + UINT priority; + ULONG priority_bit; + TX_THREAD *head_ptr; + TX_THREAD *tail_ptr; + TX_THREAD *execute_ptr; + TX_THREAD *current_thread; + ULONG combined_flags; -#ifdef TX_ENABLE_EVENT_TRACE -TX_TRACE_BUFFER_ENTRY *entry_ptr; -ULONG time_stamp = ((ULONG) 0); -#endif + #ifdef TX_ENABLE_EVENT_TRACE + TX_TRACE_BUFFER_ENTRY *entry_ptr; + ULONG time_stamp = ((ULONG) 0); + #endif -#if TX_MAX_PRIORITIES > 32 -UINT map_index; -#endif + #if TX_MAX_PRIORITIES > 32 + UINT map_index; + #endif -#ifdef TX_ENABLE_STACK_CHECKING + #ifdef TX_ENABLE_STACK_CHECKING - /* Check this thread's stack. */ - TX_THREAD_STACK_CHECK(thread_ptr) -#endif + /* Check this thread's stack. */ + TX_THREAD_STACK_CHECK(thread_ptr) + #endif #endif /* Lockout interrupts while the thread is being resumed. */ @@ -156,14 +156,14 @@ UINT map_index; #ifndef TX_INLINE_THREAD_RESUME_SUSPEND -#ifdef TX_NOT_INTERRUPTABLE + #ifdef TX_NOT_INTERRUPTABLE /* Resume the thread! */ _tx_thread_system_ni_resume(thread_ptr); /* Restore interrupts. */ TX_RESTORE -#else + #else /* Temporarily disable preemption. */ _tx_thread_preempt_disable++; @@ -173,7 +173,7 @@ UINT map_index; /* Call the actual resume service to resume the thread. */ _tx_thread_system_resume(thread_ptr); -#endif + #endif /* Determine if the thread's preemption-threshold needs to be restored. */ if (saved_thread_ptr != TX_NULL) @@ -184,18 +184,18 @@ UINT map_index; saved_thread_ptr -> tx_thread_preempt_threshold = saved_threshold; } -#ifdef TX_MISRA_ENABLE + #ifdef TX_MISRA_ENABLE /* Disable interrupts. */ TX_DISABLE /* Setup successful return status. */ status = TX_SUCCESS; -#else + #else /* Return successful completion. */ return(TX_SUCCESS); -#endif + #endif #else @@ -205,16 +205,16 @@ UINT map_index; /* Resume the thread! */ -#ifdef TX_ENABLE_EVENT_TRACE + #ifdef TX_ENABLE_EVENT_TRACE /* If trace is enabled, save the current event pointer. */ entry_ptr = _tx_trace_buffer_current_ptr; -#endif + #endif /* Log the thread status change. */ TX_TRACE_IN_LINE_INSERT(TX_TRACE_THREAD_RESUME, thread_ptr, thread_ptr -> tx_thread_state, TX_POINTER_TO_ULONG_CONVERT(&execute_ptr), TX_POINTER_TO_ULONG_CONVERT(_tx_thread_execute_ptr), TX_TRACE_INTERNAL_EVENTS) -#ifdef TX_ENABLE_EVENT_TRACE + #ifdef TX_ENABLE_EVENT_TRACE /* Save the time stamp for later comparison to verify that the event hasn't been overwritten by the time we have @@ -225,7 +225,7 @@ UINT map_index; /* Save time stamp. */ time_stamp = entry_ptr -> tx_trace_buffer_entry_time_stamp; } -#endif + #endif /* Make this thread ready. */ @@ -241,14 +241,17 @@ UINT map_index; /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, TX_READY) -#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO + /* Handle the thread resume extension, if defined*/ + TX_THREAD_SYSTEM_RESUME_EXTENSION(thread_ptr); + + #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO /* Increment the total number of thread resumptions. */ _tx_thread_performance_resume_count++; /* Increment this thread's resume count. */ thread_ptr -> tx_thread_performance_resume_count++; -#endif + #endif /* Determine if there are other threads at this priority that are ready. */ @@ -261,7 +264,7 @@ UINT map_index; thread_ptr -> tx_thread_ready_next = thread_ptr; thread_ptr -> tx_thread_ready_previous = thread_ptr; -#if TX_MAX_PRIORITIES > 32 + #if TX_MAX_PRIORITIES > 32 /* Calculate the index into the bit map array. */ map_index = priority/((UINT) 32); @@ -269,7 +272,7 @@ UINT map_index; /* Set the active bit to remember that the priority map has something set. */ TX_DIV32_BIT_SET(priority, priority_bit) _tx_thread_priority_map_active = _tx_thread_priority_map_active | priority_bit; -#endif + #endif /* Or in the thread's priority bit. */ TX_MOD32_BIT_SET(priority, priority_bit) @@ -304,13 +307,13 @@ UINT map_index; if (priority < execute_ptr -> tx_thread_preempt_threshold) { -#ifndef TX_DISABLE_PREEMPTION_THRESHOLD + #ifndef TX_DISABLE_PREEMPTION_THRESHOLD /* Determine if the preempted thread had preemption-threshold set. */ if (execute_ptr -> tx_thread_preempt_threshold != execute_ptr -> tx_thread_priority) { -#if TX_MAX_PRIORITIES > 32 + #if TX_MAX_PRIORITIES > 32 /* Calculate the index into the bit map array. */ map_index = (execute_ptr -> tx_thread_priority)/((UINT) 32); @@ -318,7 +321,7 @@ UINT map_index; /* Set the active bit to remember that the preempt map has something set. */ TX_DIV32_BIT_SET(execute_ptr -> tx_thread_priority, priority_bit) _tx_thread_preempted_map_active = _tx_thread_preempted_map_active | priority_bit; -#endif + #endif /* Remember that this thread was preempted by a thread above the thread's threshold. */ TX_MOD32_BIT_SET(execute_ptr -> tx_thread_priority, priority_bit) @@ -372,7 +375,7 @@ UINT map_index; saved_thread_ptr -> tx_thread_preempt_threshold = saved_threshold; } -#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO + #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO /* Is the execute pointer different? */ if (_tx_thread_performance_execute_log[_tx_thread_performance__execute_log_index] != _tx_thread_execute_ptr) @@ -392,9 +395,9 @@ UINT map_index; /* Log the new execute pointer. */ _tx_thread_performance_execute_log[_tx_thread_performance__execute_log_index] = _tx_thread_execute_ptr; } -#endif + #endif -#ifdef TX_ENABLE_EVENT_TRACE + #ifdef TX_ENABLE_EVENT_TRACE /* Check that the event time stamp is unchanged. A different timestamp means that a later event wrote over the thread @@ -411,19 +414,19 @@ UINT map_index; entry_ptr -> tx_trace_buffer_entry_information_field_4 = TX_POINTER_TO_ULONG_CONVERT(_tx_thread_execute_ptr); } } -#endif + #endif /* Restore interrupts. */ TX_RESTORE -#ifdef TX_ENABLE_STACK_CHECKING + #ifdef TX_ENABLE_STACK_CHECKING /* Pickup the next execute pointer. */ thread_ptr = _tx_thread_execute_ptr; /* Check this thread's stack. */ TX_THREAD_STACK_CHECK(thread_ptr) -#endif + #endif /* Now determine if preemption should take place. This is only possible if the current thread pointer is not the same as the execute thread pointer AND the system state and preempt disable flags are clear. */ @@ -431,11 +434,11 @@ UINT map_index; if (combined_flags == ((ULONG) 0)) { -#ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO + #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO /* There is another thread ready to run and will be scheduled upon return. */ _tx_thread_performance_non_idle_return_count++; -#endif + #endif /* Preemption is needed - return to the system! */ _tx_thread_system_return(); @@ -499,11 +502,11 @@ UINT map_index; /* Timestamp is the same, set the "next thread pointer" to NULL. This can be used by the trace analysis tool to show idle system conditions. */ -#ifdef TX_MISRA_ENABLE + #ifdef TX_MISRA_ENABLE entry_ptr -> tx_trace_buffer_entry_info_4 = TX_POINTER_TO_ULONG_CONVERT(_tx_thread_execute_ptr); -#else + #else entry_ptr -> tx_trace_buffer_entry_information_field_4 = TX_POINTER_TO_ULONG_CONVERT(_tx_thread_execute_ptr); -#endif + #endif } } #endif diff --git a/common/src/tx_thread_suspend.c b/common/src/tx_thread_suspend.c index ccf3ebc33..64221354f 100644 --- a/common/src/tx_thread_suspend.c +++ b/common/src/tx_thread_suspend.c @@ -309,6 +309,10 @@ ULONG time_stamp = ((ULONG) 0); /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, thread_ptr -> tx_thread_state) + + /* Handle the thread suspend extension, if defined*/ + TX_THREAD_SYSTEM_SUSPEND_EXTENSION(thread_ptr); + #ifdef TX_ENABLE_EVENT_TRACE /* If trace is enabled, save the current event pointer. */ diff --git a/common/src/tx_thread_suspend_resume_extension.c b/common/src/tx_thread_suspend_resume_extension.c new file mode 100644 index 000000000..fc78781de --- /dev/null +++ b/common/src/tx_thread_suspend_resume_extension.c @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (c) 2025 Microsoft Corporation + * + * 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. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ + +/* Include necessary system files. */ + +#include "tx_api.h" +#include "tx_trace.h" +#include "tx_thread.h" +#include "tx_initialize.h" + +/* Test only, demo of user extension. If the below is not defined, + no need to include this function at all - it will never be called */ +#ifdef TX_ENABLE_THREAD_SYSTEM_RESUME_EXTENSION + +UINT _tx_thread_system_resume_extension(TX_THREAD *thread_ptr) +{ + UINT status = 0; + if (!thread_ptr->resume_recorded) + { + thread_ptr->resume_recorded_at += 1; + } + + /* Return completion status. */ + return(status); +} + +#endif //TX_ENABLE_THREAD_SYSTEM_RESUME_EXTENSION \ No newline at end of file diff --git a/common/src/tx_thread_system_resume.c b/common/src/tx_thread_system_resume.c index 7b9f557d7..98caefe76 100644 --- a/common/src/tx_thread_system_resume.c +++ b/common/src/tx_thread_system_resume.c @@ -182,6 +182,9 @@ UINT map_index; /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, TX_READY) + /* Handle the thread resume extension, if defined*/ + TX_THREAD_SYSTEM_RESUME_EXTENSION(thread_ptr); + #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO /* Increment the total number of thread resumptions. */ @@ -435,6 +438,9 @@ UINT map_index; /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, TX_READY) + + /* Handle the thread resume extension, if defined*/ + TX_THREAD_SYSTEM_RESUME_EXTENSION(thread_ptr); } else { @@ -600,6 +606,9 @@ UINT state; /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, TX_READY) + /* Handle the thread resume extension, if defined*/ + TX_THREAD_SYSTEM_RESUME_EXTENSION(thread_ptr); + #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO /* Increment the total number of thread resumptions. */ @@ -702,6 +711,9 @@ UINT map_index; /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, TX_READY) + /* Handle the thread resume extension, if defined*/ + TX_THREAD_SYSTEM_RESUME_EXTENSION(thread_ptr); + /* Pickup priority of thread. */ priority = thread_ptr -> tx_thread_priority; diff --git a/common/src/tx_thread_system_suspend.c b/common/src/tx_thread_system_suspend.c index 33f8cac28..3899bf260 100644 --- a/common/src/tx_thread_system_suspend.c +++ b/common/src/tx_thread_system_suspend.c @@ -169,6 +169,9 @@ ULONG time_stamp = ((ULONG) 0); /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, thread_ptr -> tx_thread_state) + /* Handle the thread suspend extension, if defined*/ + TX_THREAD_SYSTEM_SUSPEND_EXTENSION(thread_ptr); + #ifdef TX_ENABLE_EVENT_TRACE /* If trace is enabled, save the current event pointer. */ @@ -761,6 +764,9 @@ ULONG time_stamp = ((ULONG) 0); /* Log the thread status change. */ TX_EL_THREAD_STATUS_CHANGE_INSERT(thread_ptr, thread_ptr -> tx_thread_state) + /* Handle the thread suspend extension, if defined*/ + TX_THREAD_SYSTEM_SUSPEND_EXTENSION(thread_ptr); + #ifdef TX_ENABLE_EVENT_TRACE /* If trace is enabled, save the current event pointer. */ diff --git a/custom_tx_user.h b/custom_tx_user.h new file mode 100644 index 000000000..ef5be4efd --- /dev/null +++ b/custom_tx_user.h @@ -0,0 +1,335 @@ +/*************************************************************************** + * Copyright (c) 2024 Microsoft Corporation + * + * 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. + * + * SPDX-License-Identifier: MIT + **************************************************************************/ + + +/**************************************************************************/ +/**************************************************************************/ +/** */ +/** ThreadX Component */ +/** */ +/** User Specific */ +/** */ +/**************************************************************************/ +/**************************************************************************/ + + +/**************************************************************************/ +/* */ +/* PORT SPECIFIC C INFORMATION RELEASE */ +/* */ +/* tx_user.h PORTABLE C */ +/* 6.3.0 */ +/* */ +/* AUTHOR */ +/* */ +/* William E. Lamie, Microsoft Corporation */ +/* */ +/* DESCRIPTION */ +/* */ +/* This file contains user defines for configuring ThreadX in specific */ +/* ways. This file will have an effect only if the application and */ +/* ThreadX library are built with TX_INCLUDE_USER_DEFINE_FILE defined. */ +/* Note that all the defines in this file may also be made on the */ +/* command line when building ThreadX library and application objects. */ +/* */ +/* RELEASE HISTORY */ +/* */ +/* DATE NAME DESCRIPTION */ +/* */ +/* 05-19-2020 William E. Lamie Initial Version 6.0 */ +/* 09-30-2020 Yuxin Zhou Modified comment(s), */ +/* resulting in version 6.1 */ +/* 03-02-2021 Scott Larson Modified comment(s), */ +/* added option to remove */ +/* FileX pointer, */ +/* resulting in version 6.1.5 */ +/* 06-02-2021 Scott Larson Added options for multiple */ +/* block pool search & delay, */ +/* resulting in version 6.1.7 */ +/* 10-15-2021 Yuxin Zhou Modified comment(s), added */ +/* user-configurable symbol */ +/* TX_TIMER_TICKS_PER_SECOND */ +/* resulting in version 6.1.9 */ +/* 04-25-2022 Wenhui Xie Modified comment(s), */ +/* optimized the definition of */ +/* TX_TIMER_TICKS_PER_SECOND, */ +/* resulting in version 6.1.11 */ +/* 10-31-2023 Xiuwen Cai Modified comment(s), */ +/* added option for random */ +/* number stack filling, */ +/* resulting in version 6.3.0 */ +/* */ +/**************************************************************************/ + +#ifndef TX_USER_H +#define TX_USER_H + + +/* Define various build options for the ThreadX port. The application should either make changes + here by commenting or un-commenting the conditional compilation defined OR supply the defines + though the compiler's equivalent of the -D option. + + For maximum speed, the following should be defined: + + TX_MAX_PRIORITIES 32 + TX_DISABLE_PREEMPTION_THRESHOLD + TX_DISABLE_REDUNDANT_CLEARING + TX_DISABLE_NOTIFY_CALLBACKS + TX_NOT_INTERRUPTABLE + TX_TIMER_PROCESS_IN_ISR + TX_REACTIVATE_INLINE + TX_DISABLE_STACK_FILLING + TX_INLINE_THREAD_RESUME_SUSPEND + + For minimum size, the following should be defined: + + TX_MAX_PRIORITIES 32 + TX_DISABLE_PREEMPTION_THRESHOLD + TX_DISABLE_REDUNDANT_CLEARING + TX_DISABLE_NOTIFY_CALLBACKS + TX_NO_FILEX_POINTER + TX_NOT_INTERRUPTABLE + TX_TIMER_PROCESS_IN_ISR + + Of course, many of these defines reduce functionality and/or change the behavior of the + system in ways that may not be worth the trade-off. For example, the TX_TIMER_PROCESS_IN_ISR + results in faster and smaller code, however, it increases the amount of processing in the ISR. + In addition, some services that are available in timers are not available from ISRs and will + therefore return an error if this option is used. This may or may not be desirable for a + given application. */ + + +/* Override various options with default values already assigned in tx_port.h. Please also refer + to tx_port.h for descriptions on each of these options. */ + +/* +#define TX_MAX_PRIORITIES 32 +#define TX_MINIMUM_STACK ???? +#define TX_THREAD_USER_EXTENSION ???? +#define TX_TIMER_THREAD_STACK_SIZE ???? +#define TX_TIMER_THREAD_PRIORITY ???? +*/ + +/* Define the common timer tick reference for use by other middleware components. The default + value is 10ms (i.e. 100 ticks, defined in tx_api.h), but may be replaced by a port-specific + version in tx_port.h or here. + Note: the actual hardware timer value may need to be changed (usually in tx_initialize_low_level). */ + +/* +#define TX_TIMER_TICKS_PER_SECOND (100UL) +*/ + +/* Determine if there is a FileX pointer in the thread control block. + By default, the pointer is there for legacy/backwards compatibility. + The pointer must also be there for applications using FileX. + Define this to save space in the thread control block. +*/ + +/* +#define TX_NO_FILEX_POINTER +*/ + +/* Determine if timer expirations (application timers, timeouts, and tx_thread_sleep calls + should be processed within the a system timer thread or directly in the timer ISR. + By default, the timer thread is used. When the following is defined, the timer expiration + processing is done directly from the timer ISR, thereby eliminating the timer thread control + block, stack, and context switching to activate it. */ + +/* +#define TX_TIMER_PROCESS_IN_ISR +*/ + +/* Determine if in-line timer reactivation should be used within the timer expiration processing. + By default, this is disabled and a function call is used. When the following is defined, + reactivating is performed in-line resulting in faster timer processing but slightly larger + code size. */ + +/* +#define TX_REACTIVATE_INLINE +*/ + +/* Determine is stack filling is enabled. By default, ThreadX stack filling is enabled, + which places an 0xEF pattern in each byte of each thread's stack. This is used by + debuggers with ThreadX-awareness and by the ThreadX run-time stack checking feature. */ + +/* +#define TX_DISABLE_STACK_FILLING +*/ + +/* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is + disabled. When the following is defined, ThreadX thread stack checking is enabled. If stack + checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING + define is negated, thereby forcing the stack fill which is necessary for the stack checking + logic. */ + +/* +#define TX_ENABLE_STACK_CHECKING +*/ + +/* Determine if random number is used for stack filling. By default, ThreadX uses a fixed + pattern for stack filling. When the following is defined, ThreadX uses a random number + for stack filling. This is effective only when TX_ENABLE_STACK_CHECKING is defined. */ + +/* +#define TX_ENABLE_RANDOM_NUMBER_STACK_FILLING +*/ + +/* Determine if preemption-threshold should be disabled. By default, preemption-threshold is + enabled. If the application does not use preemption-threshold, it may be disabled to reduce + code size and improve performance. */ + +/* +#define TX_DISABLE_PREEMPTION_THRESHOLD +*/ + +/* Determine if global ThreadX variables should be cleared. If the compiler startup code clears + the .bss section prior to ThreadX running, the define can be used to eliminate unnecessary + clearing of ThreadX global variables. */ + +/* +#define TX_DISABLE_REDUNDANT_CLEARING +*/ + +/* Determine if no timer processing is required. This option will help eliminate the timer + processing when not needed. The user will also have to comment out the call to + tx_timer_interrupt, which is typically made from assembly language in + tx_initialize_low_level. Note: if TX_NO_TIMER is used, the define TX_TIMER_PROCESS_IN_ISR + must also be used and tx_timer_initialize must be removed from ThreadX library. */ + +/* +#define TX_NO_TIMER +#ifndef TX_TIMER_PROCESS_IN_ISR +#define TX_TIMER_PROCESS_IN_ISR +#endif +*/ + +/* Determine if the notify callback option should be disabled. By default, notify callbacks are + enabled. If the application does not use notify callbacks, they may be disabled to reduce + code size and improve performance. */ + +/* +#define TX_DISABLE_NOTIFY_CALLBACKS +*/ + + +/* Determine if the tx_thread_resume and tx_thread_suspend services should have their internal + code in-line. This results in a larger image, but improves the performance of the thread + resume and suspend services. */ + +/* +#define TX_INLINE_THREAD_RESUME_SUSPEND +*/ + + +/* Determine if the internal ThreadX code is non-interruptable. This results in smaller code + size and less processing overhead, but increases the interrupt lockout time. */ + +/* +#define TX_NOT_INTERRUPTABLE +*/ + + +/* Determine if the trace event logging code should be enabled. This causes slight increases in + code size and overhead, but provides the ability to generate system trace information which + is available for viewing in TraceX. */ + +/* +#define TX_ENABLE_EVENT_TRACE +*/ + + +/* Determine if block pool performance gathering is required by the application. When the following is + defined, ThreadX gathers various block pool performance information. */ + +/* +#define TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if byte pool performance gathering is required by the application. When the following is + defined, ThreadX gathers various byte pool performance information. */ + +/* +#define TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if event flags performance gathering is required by the application. When the following is + defined, ThreadX gathers various event flags performance information. */ + +/* +#define TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if mutex performance gathering is required by the application. When the following is + defined, ThreadX gathers various mutex performance information. */ + +/* +#define TX_MUTEX_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if queue performance gathering is required by the application. When the following is + defined, ThreadX gathers various queue performance information. */ + +/* +#define TX_QUEUE_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if semaphore performance gathering is required by the application. When the following is + defined, ThreadX gathers various semaphore performance information. */ + +/* +#define TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if thread performance gathering is required by the application. When the following is + defined, ThreadX gathers various thread performance information. */ + +/* +#define TX_THREAD_ENABLE_PERFORMANCE_INFO +*/ + +/* Determine if timer performance gathering is required by the application. When the following is + defined, ThreadX gathers various timer performance information. */ + +/* +#define TX_TIMER_ENABLE_PERFORMANCE_INFO +*/ + +/* Override options for byte pool searches of multiple blocks. */ + +/* +#define TX_BYTE_POOL_MULTIPLE_BLOCK_SEARCH 20 +*/ + +/* Override options for byte pool search delay to avoid thrashing. */ + +/* +#define TX_BYTE_POOL_DELAY_VALUE 3 +*/ + +/* Define user-specified additional fields to be stored in TX_THREAD */ +#define TX_THREAD_USER_EXTENSION UCHAR resume_recorded; \ + ULONG resume_recorded_at; \ + UCHAR suspend_recorded; \ + ULONG suspend_recorded_at; + +/* This is one way to define the extension. Because it's a macro, it + cannot handle static allocations internally, nor does it have a + proper calling context for tracing purposes. */ +#define TX_THREAD_SYSTEM_SUSPEND_EXTENSION(thread_ptr) \ +do { \ + if (!thread_ptr->suspend_recorded) \ + { \ + thread_ptr->suspend_recorded_at += 1; \ + thread_ptr->suspend_recorded = 1; \ + } \ +} while(0) + +#endif +