Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5740d38
Implemented self-contained Windows x64 port and regression support
fdesbiens Apr 3, 2026
25f2dce
Optimized Win64 simulator scheduling and build wrapper
fdesbiens Apr 6, 2026
a50740b
Fixed Linux regression test source generation
fdesbiens Apr 6, 2026
31b60a2
Added Win64 SMP port and fixed scheduler handoff races
fdesbiens Apr 29, 2026
9fb730b
Fixed Win64 timing behavior and removed test workarounds
fdesbiens Apr 29, 2026
4fe181e
win64_smp: improve host scheduling behavior
fdesbiens May 1, 2026
8f4fe3f
perf(win64_smp): reduce SuspendThread/ResumeThread overhead and add s…
fdesbiens May 1, 2026
42996a7
perf(win64_smp): skip SuspendThread when spinning on Win32 CS (type-4)
fdesbiens May 2, 2026
e90c8d8
perf(win64-smp): Round 4 - reduce SwitchToThread frequency, TLS hint …
fdesbiens May 2, 2026
2ca7a33
test(win64-smp): add Round 4 verified test results (78.24 s, 109/109)
fdesbiens May 2, 2026
dfeaa06
Tests-Win-After6: Win32 priority mapping experiment (reverted)
fdesbiens May 2, 2026
185f417
perf(win64_smp): reduced Windows regression runtime
fdesbiens May 5, 2026
8e91e9b
chore(windows): updated port versions and comment formatting
fdesbiens May 5, 2026
1bbd882
fix(win64): synchronized host thread startup
fdesbiens May 6, 2026
3c5e999
fix(win64): improved timer precision and host thread teardown
fdesbiens May 7, 2026
cfab11c
test(windows): added clean CTest runs and dev shell reuse
fdesbiens May 7, 2026
18a6074
test(regression): removed stale Windows accommodations
fdesbiens May 7, 2026
9932713
Merge branch 'dev' into win64
fdesbiens May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)

# Set up the project
project(threadx
LANGUAGES C ASM
)

if(NOT DEFINED THREADX_ARCH)
message(FATAL_ERROR "Error: THREADX_ARCH not defined")
endif()
if(NOT DEFINED THREADX_TOOLCHAIN)
message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined")
endif()

# The Windows simulation ports build cleanly without executable try-compiles.
if((THREADX_ARCH STREQUAL "win32") OR (THREADX_ARCH STREQUAL "win64"))
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
endif()

# Set up the project. The Windows simulation ports do not use assembly and
# avoiding ASM language enablement keeps MSVC configuration on the CLI path
# deterministic.
if((THREADX_ARCH STREQUAL "win32") OR (THREADX_ARCH STREQUAL "win64"))
project(threadx
LANGUAGES C
)
else()
project(threadx
LANGUAGES C ASM
)

option(THREADX_SMP "Build ThreadX SMP version" OFF)

if(THREADX_SMP)
Expand Down Expand Up @@ -87,4 +99,4 @@ set(CPACK_SOURCE_IGNORE_FILES
".*~$"
)
set(CPACK_VERBATIM_VARIABLES YES)
include(CPack)
include(CPack)
12 changes: 3 additions & 9 deletions cmake/win32.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_SYSTEM_PROCESSOR x86)

set(THREADX_ARCH "win32")
set(THREADX_TOOLCHAIN "vs_2019")

set(WIN32_FLAGS "")

set(CMAKE_C_FLAGS "${WIN32_FLAGS} " CACHE INTERNAL "c compiler flags")
set(CMAKE_CXX_FLAGS "${WIN32_FLAGS} -fno-rtti -fno-exceptions" CACHE INTERNAL "cxx compiler flags")
set(CMAKE_ASM_FLAGS "${WIN32_FLAGS} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")
set(CMAKE_EXE_LINKER_FLAGS "${WIN32_FLAGS} ${LD_FLAGS}" CACHE INTERNAL "exe link flags")

# this makes the test compiles use static library option so that we don't need to pre-set linker flags and scripts
# This makes the test compiles use the static library option so that the
# compiler environment can be discovered from the active MSVC shell.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
9 changes: 9 additions & 0 deletions cmake/win64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR AMD64)

set(THREADX_ARCH "win64")
set(THREADX_TOOLCHAIN "vs_2022")

# This makes the test compiles use the static library option so that the
# compiler environment can be discovered from the active MSVC shell.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
7 changes: 6 additions & 1 deletion common/src/tx_initialize_high_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,22 @@ VOID _tx_initialize_high_level(VOID)
/* Initialize the event log, if enabled. */
TX_EL_INITIALIZE


/* Call the thread control initialization function. */
_tx_thread_initialize();


#ifndef TX_NO_TIMER


/* Call the timer control initialization function. */
_tx_timer_initialize();

#endif

#ifndef TX_DISABLE_REDUNDANT_CLEARING


/* Call the semaphore initialization function. */
_tx_semaphore_initialize();

Expand All @@ -139,6 +144,6 @@ VOID _tx_initialize_high_level(VOID)

/* Call the mutex initialization function. */
_tx_mutex_initialize();

#endif
}

4 changes: 3 additions & 1 deletion common/src/tx_initialize_kernel_enter.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,18 @@ VOID _tx_initialize_kernel_enter(VOID)
/* Call any port specific preprocessing. */
TX_PORT_SPECIFIC_PRE_INITIALIZATION


/* Invoke the low-level initialization to handle all processor specific
initialization issues. */
_tx_initialize_low_level();


/* Invoke the high-level initialization to exercise all of the
ThreadX components and the application's initialization
function. */
_tx_initialize_high_level();


/* Call any port specific post-processing. */
TX_PORT_SPECIFIC_POST_INITIALIZATION
}
Expand Down Expand Up @@ -150,4 +153,3 @@ VOID _tx_initialize_kernel_enter(VOID)
TX_SAFETY_CRITICAL_EXCEPTION(__FILE__, __LINE__, 0);
#endif
}

3 changes: 2 additions & 1 deletion common/src/tx_timer_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ UINT status;
do
{


/* Create the system timer thread. */
status = _tx_thread_create(&_tx_timer_thread,
TX_CONST_CHAR_TO_CHAR_POINTER_CONVERT("System Timer Thread"),
Expand All @@ -253,6 +254,7 @@ UINT status;
_tx_timer_stack_start, _tx_timer_stack_size,
_tx_timer_priority, _tx_timer_priority, TX_NO_TIME_SLICE, TX_DONT_START);


#ifdef TX_SAFETY_CRITICAL

/* Check return from thread create - if an error is detected throw an exception. */
Expand Down Expand Up @@ -295,4 +297,3 @@ UINT status;
#endif
#endif
}

1 change: 0 additions & 1 deletion common_smp/src/tx_thread_system_resume.c
Original file line number Diff line number Diff line change
Expand Up @@ -960,4 +960,3 @@ VOID _tx_thread_system_ni_resume(TX_THREAD *thread_ptr)
_tx_thread_system_resume(thread_ptr);
}
#endif

1 change: 0 additions & 1 deletion common_smp/src/tx_thread_system_suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,4 +984,3 @@ VOID _tx_thread_system_ni_suspend(TX_THREAD *thread_ptr, ULONG timeout)
_tx_thread_system_suspend(thread_ptr);
}
#endif

105 changes: 96 additions & 9 deletions ports/win32/vs_2019/inc/tx_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* PORT SPECIFIC C INFORMATION RELEASE */
/* */
/* tx_port.h Win32/Visual */
/* 6.1 */
/* 6.5.1.202602 */
/* */
/* AUTHOR */
/* */
Expand Down Expand Up @@ -66,6 +66,95 @@
#include <stdlib.h>
#include <string.h>

/* Define automated coverage test extensions required by the regression tests. */

typedef unsigned int TEST_FLAG;
extern TEST_FLAG threadx_byte_allocate_loop_test;
extern TEST_FLAG threadx_byte_release_loop_test;
extern TEST_FLAG threadx_mutex_suspension_put_test;
extern TEST_FLAG threadx_mutex_suspension_priority_test;
#ifndef TX_TIMER_PROCESS_IN_ISR
extern TEST_FLAG threadx_delete_timer_thread;
#endif
extern void abort_and_resume_byte_allocating_thread(void);
extern void abort_all_threads_suspended_on_mutex(void);
extern void suspend_lowest_priority(void);
#ifndef TX_TIMER_PROCESS_IN_ISR
extern void delete_timer_thread(void);
#endif
extern TEST_FLAG test_stack_analyze_flag;
extern TEST_FLAG test_initialize_flag;
extern TEST_FLAG test_forced_mutex_timeout;

#ifdef TX_REGRESSION_TEST

#define TX_BYTE_ALLOCATE_EXTENSION if (threadx_byte_allocate_loop_test == ((TEST_FLAG) 1)) \
{ \
pool_ptr -> tx_byte_pool_owner = TX_NULL; \
threadx_byte_allocate_loop_test = ((TEST_FLAG) 0); \
}

#define TX_BYTE_RELEASE_EXTENSION if (threadx_byte_release_loop_test == ((TEST_FLAG) 1)) \
{ \
threadx_byte_release_loop_test = ((TEST_FLAG) 0); \
abort_and_resume_byte_allocating_thread(); \
}

#define TX_MUTEX_PUT_EXTENSION_1 if (threadx_mutex_suspension_put_test == ((TEST_FLAG) 1)) \
{ \
threadx_mutex_suspension_put_test = ((TEST_FLAG) 0); \
abort_all_threads_suspended_on_mutex(); \
}

#define TX_MUTEX_PUT_EXTENSION_2 if (test_forced_mutex_timeout == ((TEST_FLAG) 1)) \
{ \
test_forced_mutex_timeout = ((TEST_FLAG) 0); \
_tx_thread_wait_abort(mutex_ptr -> tx_mutex_suspension_list); \
}

#define TX_MUTEX_PRIORITY_CHANGE_EXTENSION if (threadx_mutex_suspension_priority_test == ((TEST_FLAG) 1)) \
{ \
threadx_mutex_suspension_priority_test = ((TEST_FLAG) 0); \
suspend_lowest_priority(); \
}

#ifndef TX_TIMER_PROCESS_IN_ISR
#define TX_TIMER_INITIALIZE_EXTENSION(a) if (threadx_delete_timer_thread == ((TEST_FLAG) 1)) \
{ \
threadx_delete_timer_thread = ((TEST_FLAG) 0); \
delete_timer_thread(); \
(a) = ((UINT) 1); \
}
#endif

#define TX_THREAD_STACK_ANALYZE_EXTENSION if (test_stack_analyze_flag == ((TEST_FLAG) 1)) \
{ \
thread_ptr -> tx_thread_id = ((TEST_FLAG) 0); \
test_stack_analyze_flag = ((TEST_FLAG) 0); \
} \
else if (test_stack_analyze_flag == ((TEST_FLAG) 2)) \
{ \
stack_ptr = thread_ptr -> tx_thread_stack_start; \
test_stack_analyze_flag = ((TEST_FLAG) 0); \
} \
else if (test_stack_analyze_flag == ((TEST_FLAG) 3)) \
{ \
*stack_ptr = TX_STACK_FILL; \
test_stack_analyze_flag = ((TEST_FLAG) 0); \
} \
else \
{ \
test_stack_analyze_flag = ((TEST_FLAG) 0); \
}

#define TX_INITIALIZE_KERNEL_ENTER_EXTENSION if (test_initialize_flag == ((TEST_FLAG) 1)) \
{ \
test_initialize_flag = ((TEST_FLAG) 0); \
return; \
}

#endif


/* Define performance metric symbols. */

Expand Down Expand Up @@ -101,7 +190,6 @@
#define TX_TIMER_ENABLE_PERFORMANCE_INFO
#endif


/* Enable trace info. */

#ifndef TX_ENABLE_EVENT_TRACE
Expand Down Expand Up @@ -198,7 +286,7 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
#define TX_TRACE_TIME_SOURCE *((ULONG *) 0x0a800024)
#define TX_TRACE_TIME_MASK 0x0000FFFFUL

*/
*/

#ifndef TX_TRACE_TIME_SOURCE
#define TX_TRACE_TIME_SOURCE ((ULONG) (_tx_win32_time_stamp.LowPart));
Expand Down Expand Up @@ -232,7 +320,6 @@ void _tx_initialize_start_interrupts(void);

#define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION _tx_initialize_start_interrupts();


/* 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
Expand Down Expand Up @@ -413,7 +500,7 @@ VOID _tx_thread_interrupt_restore(UINT previous_posture);

#ifdef TX_THREAD_INIT
CHAR _tx_version_id[] =
"(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX Win32/Visual Studio Version 6.5.0.202601 *";
"(c) 2024 Microsoft Corp. (c) 2026-present Eclipse ThreadX contributors. * ThreadX Win32/Visual Studio Version 6.5.1.202602 *";
#else
extern CHAR _tx_version_id[];
#endif
Expand All @@ -437,11 +524,11 @@ extern LARGE_INTEGER _tx_win32_time_stamp;
#endif

#ifndef TX_TIMER_PERIODIC
#ifdef TX_WIN32_SLOW_TIMER
#define TX_TIMER_PERIODIC TX_WIN32_SLOW_TIMER
#else
#define TX_TIMER_PERIODIC 10
#endif

#endif




#endif
3 changes: 2 additions & 1 deletion ports/win32/vs_2019/src/tx_initialize_low_level.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* SPDX-License-Identifier: MIT
**************************************************************************/

// Some portions generated by Codex (gpt 5.4).

/**************************************************************************/
/**************************************************************************/
Expand Down Expand Up @@ -280,4 +281,4 @@ VOID CALLBACK _tx_win32_timer_interrupt(UINT wTimerID, UINT msg, DWORD dwUser, D

/* Call ThreadX context restore for interrupt completion. */
_tx_thread_context_restore();
}
}
19 changes: 19 additions & 0 deletions ports/win64/vs_2022/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
target_sources(${PROJECT_NAME}
PRIVATE
# {{BEGIN_TARGET_SOURCES}}
${CMAKE_CURRENT_LIST_DIR}/src/tx_initialize_low_level.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_restore.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_context_save.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_interrupt_control.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_schedule.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_stack_build.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_thread_system_return.c
${CMAKE_CURRENT_LIST_DIR}/src/tx_timer_interrupt.c

# {{END_TARGET_SOURCES}}
)

target_include_directories(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/inc
)
Loading