summaryrefslogtreecommitdiff
path: root/ports/win32/vs_2019/src
diff options
context:
space:
mode:
authorFrédéric Desbiens <[email protected]>2026-03-06 19:27:49 +0100
committerGitHub <[email protected]>2026-03-06 19:27:49 +0100
commit3726d7906b4808bfec7855fc088e073199df9120 (patch)
tree8789bfd03d1d49e1967e80d04aa4ff606fda43eb /ports/win32/vs_2019/src
parent4b6e8100d932a3a67b34c6eb17f84f3bffb9e2ae (diff)
parentc3259a216026372e3833dd8996a68f77e8595fbd (diff)
Merge pull request #510 from eclipse-threadx/devv6.5.0.202601_rel
Merge changes ahead of the v6.5.0.202601 release
Diffstat (limited to 'ports/win32/vs_2019/src')
-rw-r--r--ports/win32/vs_2019/src/tx_initialize_low_level.c95
-rw-r--r--ports/win32/vs_2019/src/tx_thread_context_restore.c75
-rw-r--r--ports/win32/vs_2019/src/tx_thread_context_save.c69
-rw-r--r--ports/win32/vs_2019/src/tx_thread_interrupt_control.c101
-rw-r--r--ports/win32/vs_2019/src/tx_thread_schedule.c111
-rw-r--r--ports/win32/vs_2019/src/tx_thread_stack_build.c69
-rw-r--r--ports/win32/vs_2019/src/tx_thread_system_return.c121
-rw-r--r--ports/win32/vs_2019/src/tx_timer_interrupt.c75
8 files changed, 338 insertions, 378 deletions
diff --git a/ports/win32/vs_2019/src/tx_initialize_low_level.c b/ports/win32/vs_2019/src/tx_initialize_low_level.c
index b62d1615..dd364d06 100644
--- a/ports/win32/vs_2019/src/tx_initialize_low_level.c
+++ b/ports/win32/vs_2019/src/tx_initialize_low_level.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Initialize */
/** */
@@ -43,7 +44,7 @@ extern TX_THREAD *_tx_thread_current_ptr;
/* Define simulated timer interrupt. This is done inside a thread, which is
- how other interrupts may be defined as well. See code below for an
+ how other interrupts may be defined as well. See code below for an
example. */
UINT _tx_win32_timer_id;
@@ -115,22 +116,22 @@ void _tx_win32_debug_entry_insert(char *action, char *file, unsigned long lin
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread = _tx_thread_current_ptr;
if (_tx_thread_current_ptr)
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread_id = _tx_thread_current_ptr -> tx_thread_win32_thread_id;
- else
+ else
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_current_thread_id = 0;
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread = _tx_thread_execute_ptr;
if (_tx_thread_execute_ptr)
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread_id = _tx_thread_execute_ptr -> tx_thread_win32_thread_id;
- else
+ else
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_execute_thread_id = 0;
_tx_win32_debug_entry_array[_tx_win32_debug_entry_index].tx_win32_debug_entry_running_id = GetCurrentThreadId();
/* Now move to the next entry. */
_tx_win32_debug_entry_index++;
-
+
/* Determine if we need to wrap the list. */
if (_tx_win32_debug_entry_index >= TX_WIN32_DEBUG_EVENT_SIZE)
{
-
+
/* Yes, wrap the list! */
_tx_win32_debug_entry_index = 0;
}
@@ -156,50 +157,44 @@ VOID _tx_thread_context_restore(VOID);
extern VOID *_tx_initialize_unused_memory;
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_initialize_low_level Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_initialize_low_level Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is responsible for any low-level processor */
-/* initialization, including setting up interrupt vectors, setting */
-/* up a periodic timer interrupt source, saving the system stack */
-/* pointer for use in ISR processing later, and finding the first */
-/* available RAM memory address for tx_application_define. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* CreateMutex Win32 create mutex */
-/* CreateThread Win32 create thread */
-/* CreateSemaphore Win32 create semaphore */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* SetProcessAffinityMask Win32 process affinity set */
-/* SetThreadPriority Win32 set thread priority */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_initialize_kernel_enter ThreadX entry function */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is responsible for any low-level processor */
+/* initialization, including setting up interrupt vectors, setting */
+/* up a periodic timer interrupt source, saving the system stack */
+/* pointer for use in ISR processing later, and finding the first */
+/* available RAM memory address for tx_application_define. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* CreateMutex Win32 create mutex */
+/* CreateThread Win32 create thread */
+/* CreateSemaphore Win32 create semaphore */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* SetProcessAffinityMask Win32 process affinity set */
+/* SetThreadPriority Win32 set thread priority */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_initialize_kernel_enter ThreadX entry function */
/* */
/**************************************************************************/
VOID _tx_initialize_low_level(VOID)
@@ -213,7 +208,7 @@ VOID _tx_initialize_low_level(VOID)
/* Limit this ThreadX simulation on Win32 to a single core. */
if (SetProcessAffinityMask( GetCurrentProcess(), 1 ) == 0)
{
-
+
/* Error restricting the process to one core. */
printf("ThreadX Win32 error restricting the process to one core!\n");
while(1)
@@ -235,7 +230,7 @@ VOID _tx_initialize_low_level(VOID)
_tx_win32_critical_section.tx_win32_critical_section_mutex_handle = CreateMutex(NULL, FALSE, NULL);
_tx_win32_critical_section.tx_win32_critical_section_nested_count = 0;
_tx_win32_critical_section.tx_win32_critical_section_owner = 0;
-
+
/* Create the semaphore that regulates when the scheduler executes. */
_tx_win32_scheduler_semaphore = CreateSemaphore(NULL, 0, 1, NULL);
@@ -247,7 +242,7 @@ VOID _tx_initialize_low_level(VOID)
/* This routine is called after initialization is complete in order to start
- all interrupt threads. Interrupt threads in addition to the timer may
+ all interrupt threads. Interrupt threads in addition to the timer may
be added to this routine as well. */
void _tx_initialize_start_interrupts(void)
diff --git a/ports/win32/vs_2019/src/tx_thread_context_restore.c b/ports/win32/vs_2019/src/tx_thread_context_restore.c
index 3272348d..36fa1e4b 100644
--- a/ports/win32/vs_2019/src/tx_thread_context_restore.c
+++ b/ports/win32/vs_2019/src/tx_thread_context_restore.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,47 +31,41 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_context_restore Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_context_restore Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function restores the interrupt context if it is processing a */
-/* nested interrupt. If not, it returns to the interrupt thread if no */
-/* preemption is necessary. Otherwise, if preemption is necessary or */
-/* if no thread was running, the function returns to the scheduler. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* ReleaseSemaphore Win32 release semaphore */
-/* ResumeThread Win32 resume thread */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* ISRs Interrupt Service Routines */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function restores the interrupt context if it is processing a */
+/* nested interrupt. If not, it returns to the interrupt thread if no */
+/* preemption is necessary. Otherwise, if preemption is necessary or */
+/* if no thread was running, the function returns to the scheduler. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* ReleaseSemaphore Win32 release semaphore */
+/* ResumeThread Win32 resume thread */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* ISRs Interrupt Service Routines */
/* */
/**************************************************************************/
VOID _tx_thread_context_restore(VOID)
@@ -97,7 +92,7 @@ VOID _tx_thread_context_restore(VOID)
if ((_tx_thread_preempt_disable == 0) && (_tx_thread_current_ptr != _tx_thread_execute_ptr))
{
- /* Preempt the running application thread. We don't need to suspend the
+ /* Preempt the running application thread. We don't need to suspend the
application thread since that is done in the context save processing. */
/* Indicate that this thread was suspended asynchronously. */
diff --git a/ports/win32/vs_2019/src/tx_thread_context_save.c b/ports/win32/vs_2019/src/tx_thread_context_save.c
index b39fc52c..2f4afb40 100644
--- a/ports/win32/vs_2019/src/tx_thread_context_save.c
+++ b/ports/win32/vs_2019/src/tx_thread_context_save.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,45 +31,39 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_context_save Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_context_save Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function saves the context of an executing thread in the */
-/* beginning of interrupt processing. The function also ensures that */
-/* the system stack is used upon return to the calling ISR. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* SuspendThread Win32 thread suspend */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* ISRs */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function saves the context of an executing thread in the */
+/* beginning of interrupt processing. The function also ensures that */
+/* the system stack is used upon return to the calling ISR. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* SuspendThread Win32 thread suspend */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* ISRs */
/* */
/**************************************************************************/
VOID _tx_thread_context_save(VOID)
diff --git a/ports/win32/vs_2019/src/tx_thread_interrupt_control.c b/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
index 5b99eeb8..019aabef 100644
--- a/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
+++ b/ports/win32/vs_2019/src/tx_thread_interrupt_control.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -49,49 +50,43 @@ VOID _tx_thread_interrupt_restore(UINT previous_posture)
}
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_interrupt_control Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_interrupt_control Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is responsible for changing the interrupt lockout */
-/* posture of the system. */
-/* */
-/* INPUT */
-/* */
-/* new_posture New interrupt lockout posture */
-/* */
-/* OUTPUT */
-/* */
-/* old_posture Old interrupt lockout posture */
-/* */
-/* CALLS */
-/* */
-/* ExitThread Win32 thread exit */
-/* GetCurrentThread Win32 get current thread */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* GetThreadPriority Win32 get thread priority */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* _tx_win32_critical_section_release_all */
-/* Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* Application Code */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is responsible for changing the interrupt lockout */
+/* posture of the system. */
+/* */
+/* INPUT */
+/* */
+/* new_posture New interrupt lockout posture */
+/* */
+/* OUTPUT */
+/* */
+/* old_posture Old interrupt lockout posture */
+/* */
+/* CALLS */
+/* */
+/* ExitThread Win32 thread exit */
+/* GetCurrentThread Win32 get current thread */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* GetThreadPriority Win32 get thread priority */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* _tx_win32_critical_section_release_all */
+/* Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* Application Code */
/* */
/**************************************************************************/
UINT _tx_thread_interrupt_control(UINT new_posture)
@@ -99,9 +94,9 @@ UINT _tx_thread_interrupt_control(UINT new_posture)
UINT old_posture;
HANDLE threadhandle;
-int threadpriority;
+int threadpriority;
DWORD threadid;
-TX_THREAD *thread_ptr;
+TX_THREAD *thread_ptr;
/* Enter Win32 critical section. */
@@ -116,7 +111,7 @@ TX_THREAD *thread_ptr;
_tx_win32_debug_entry_insert("RESTORE", __FILE__, __LINE__);
}
else
- {
+ {
/* Disable. */
_tx_win32_debug_entry_insert("DISABLE", __FILE__, __LINE__);
}
@@ -131,24 +126,24 @@ TX_THREAD *thread_ptr;
thread_ptr = _tx_thread_current_ptr;
/* Pickup the priority of the current thread. */
- threadpriority = GetThreadPriority(threadhandle);
+ threadpriority = GetThreadPriority(threadhandle);
/* Pickup the ID of the current thread. */
threadid = GetCurrentThreadId();
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!thread_ptr) || (thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!thread_ptr) || (thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
- /* This indicates the Win32 thread was actually terminated by ThreadX is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX is only
being allowed to run in order to cleanup its resources. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
/* Exit this thread. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Determine the current interrupt lockout condition. */
if (_tx_win32_critical_section.tx_win32_critical_section_nested_count == 1)
@@ -185,7 +180,7 @@ TX_THREAD *thread_ptr;
_tx_win32_global_int_disabled_flag = TX_TRUE;
}
}
- else if (thread_ptr)
+ else if (thread_ptr)
{
/* Determine how to apply the new posture. */
diff --git a/ports/win32/vs_2019/src/tx_thread_schedule.c b/ports/win32/vs_2019/src/tx_thread_schedule.c
index 9b8092da..d67efee8 100644
--- a/ports/win32/vs_2019/src/tx_thread_schedule.c
+++ b/ports/win32/vs_2019/src/tx_thread_schedule.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,48 +31,42 @@
#include "tx_timer.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_schedule Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_schedule Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function waits for a thread control block pointer to appear in */
-/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
-/* in the variable, the corresponding thread is resumed. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* This function waits for a thread control block pointer to appear in */
+/* the _tx_thread_execute_ptr variable. Once a thread pointer appears */
+/* in the variable, the corresponding thread is resumed. */
+/* */
+/* INPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
-/* ReleaseSemaphore Win32 release semaphore */
-/* ResumeThread Win32 resume thread */
-/* Sleep Win32 thread sleep */
-/* WaitForSingleObject Win32 wait on a semaphore */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_initialize_kernel_enter ThreadX entry function */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* ReleaseSemaphore Win32 release semaphore */
+/* ResumeThread Win32 resume thread */
+/* Sleep Win32 thread sleep */
+/* WaitForSingleObject Win32 wait on a semaphore */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_initialize_kernel_enter ThreadX entry function */
/* */
/**************************************************************************/
VOID _tx_thread_schedule(VOID)
@@ -93,7 +88,7 @@ VOID _tx_thread_schedule(VOID)
/* Debug entry. */
_tx_win32_debug_entry_insert("SCHEDULE-wake_up", __FILE__, __LINE__);
- /* Determine if there is a thread ready to execute AND all ISRs
+ /* Determine if there is a thread ready to execute AND all ISRs
are complete. */
if ((_tx_thread_execute_ptr != TX_NULL) && (_tx_thread_system_state == 0))
{
@@ -111,8 +106,8 @@ VOID _tx_thread_schedule(VOID)
Sleep(2);
}
}
-
- /* Yes! We have a thread to execute. Note that the critical section is already
+
+ /* Yes! We have a thread to execute. Note that the critical section is already
active from the scheduling loop above. */
/* Setup the current thread pointer. */
@@ -168,12 +163,12 @@ TX_THREAD *thread_ptr;
/* Is the protection owned? */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Simply increment the nested counter. */
critical_section -> tx_win32_critical_section_nested_count++;
}
else
- {
+ {
/* Pickup the current thread pointer. */
thread_ptr = _tx_thread_current_ptr;
@@ -182,12 +177,12 @@ TX_THREAD *thread_ptr;
while (WaitForSingleObject(critical_section -> tx_win32_critical_section_mutex_handle, 3) != WAIT_OBJECT_0)
{
}
-
+
/* At this point we have the mutex. */
-
+
/* Increment the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count = 1;
-
+
/* Remember the owner. */
critical_section -> tx_win32_critical_section_owner = GetCurrentThreadId();
}
@@ -201,25 +196,25 @@ void _tx_win32_critical_section_release(TX_WIN32_CRITICAL_SECTION *critical_s
/* Ensure the caller is the mutex owner. */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Determine if there is protection. */
if (critical_section -> tx_win32_critical_section_nested_count)
{
-
+
/* Decrement the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count--;
-
+
/* Determine if the critical section is now being released. */
if (critical_section -> tx_win32_critical_section_nested_count == 0)
{
-
+
/* Yes, it is being released clear the owner. */
critical_section -> tx_win32_critical_section_owner = 0;
/* Finally, release the mutex. */
if (ReleaseMutex(critical_section -> tx_win32_critical_section_mutex_handle) != TX_TRUE)
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
@@ -239,7 +234,7 @@ void _tx_win32_critical_section_release(TX_WIN32_CRITICAL_SECTION *critical_s
}
else
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
@@ -252,14 +247,14 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
/* Ensure the caller is the mutex owner. */
if (critical_section -> tx_win32_critical_section_owner == GetCurrentThreadId())
{
-
+
/* Determine if there is protection. */
if (critical_section -> tx_win32_critical_section_nested_count)
{
-
+
/* Clear the nesting counter. */
critical_section -> tx_win32_critical_section_nested_count = 0;
-
+
/* Yes, it is being release clear the owner. */
critical_section -> tx_win32_critical_section_owner = 0;
@@ -270,7 +265,7 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
/* Increment the system error counter. */
_tx_win32_system_error++;
}
-
+
/* Just in case, make sure there the mutex is not owned. */
while (ReleaseMutex(critical_section -> tx_win32_critical_section_mutex_handle) == TX_TRUE)
{
@@ -282,7 +277,7 @@ void _tx_win32_critical_section_release_all(TX_WIN32_CRITICAL_SECTION *cri
}
else
{
-
+
/* Increment the system error counter. */
_tx_win32_system_error++;
}
diff --git a/ports/win32/vs_2019/src/tx_thread_stack_build.c b/ports/win32/vs_2019/src/tx_thread_stack_build.c
index 55b74c2b..da51e7c4 100644
--- a/ports/win32/vs_2019/src/tx_thread_stack_build.c
+++ b/ports/win32/vs_2019/src/tx_thread_stack_build.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -35,47 +36,41 @@
DWORD WINAPI _tx_win32_thread_entry(LPVOID p);
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_stack_build Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_stack_build Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
+/* */
/* This function builds a stack frame on the supplied thread's stack. */
/* The stack frame results in a fake interrupt return to the supplied */
-/* function pointer. */
-/* */
-/* INPUT */
-/* */
+/* function pointer. */
+/* */
+/* INPUT */
+/* */
/* thread_ptr Pointer to thread control blk */
/* function_ptr Pointer to return function */
-/* */
-/* OUTPUT */
-/* */
+/* */
+/* OUTPUT */
+/* */
/* None */
-/* */
-/* CALLS */
-/* */
-/* CreateThread Win32 create thread */
-/* ResumeThread Win32 resume thread */
-/* SetThreadPriority Win32 set thread priority */
-/* */
-/* CALLED BY */
-/* */
-/* _tx_thread_create Create thread service */
-/* _tx_thread_reset Reset thread service */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* CALLS */
+/* */
+/* CreateThread Win32 create thread */
+/* ResumeThread Win32 resume thread */
+/* SetThreadPriority Win32 set thread priority */
+/* */
+/* CALLED BY */
+/* */
+/* _tx_thread_create Create thread service */
+/* _tx_thread_reset Reset thread service */
/* */
/**************************************************************************/
VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
@@ -83,7 +78,7 @@ VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
/* Create a Win32 thread for the application thread. */
thread_ptr -> tx_thread_win32_thread_handle =
- CreateThread(NULL, 0, _tx_win32_thread_entry, (LPVOID) thread_ptr, CREATE_SUSPENDED,
+ CreateThread(NULL, 0, _tx_win32_thread_entry, (LPVOID) thread_ptr, CREATE_SUSPENDED,
&(thread_ptr -> tx_thread_win32_thread_id));
/* Check for a good thread create. */
@@ -116,11 +111,11 @@ VOID _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID))
}
}
- /* Setup the thread suspension type to solicited thread suspension.
+ /* Setup the thread suspension type to solicited thread suspension.
Pseudo interrupt handlers will suspend with this field set to 1. */
thread_ptr -> tx_thread_win32_suspension_type = 0;
- /* Clear the disabled count that will keep track of the
+ /* Clear the disabled count that will keep track of the
tx_interrupt_control nesting. */
thread_ptr -> tx_thread_win32_int_disabled_flag = 0;
diff --git a/ports/win32/vs_2019/src/tx_thread_system_return.c b/ports/win32/vs_2019/src/tx_thread_system_return.c
index c5870ee2..60176135 100644
--- a/ports/win32/vs_2019/src/tx_thread_system_return.c
+++ b/ports/win32/vs_2019/src/tx_thread_system_return.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Thread */
/** */
@@ -30,53 +31,47 @@
#include <stdio.h>
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_thread_system_return Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_thread_system_return Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function is target processor specific. It is used to transfer */
-/* control from a thread back to the system. Only a minimal context */
-/* is saved since the compiler assumes temp registers are going to get */
-/* slicked by a function call anyway. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* _tx_win32_critical_section_release_all */
-/* Release critical section */
-/* ExitThread Win32 thread exit */
-/* GetCurrentThread Win32 get current thread */
-/* GetCurrentThreadId Win32 get current thread ID */
-/* GetThreadPriority Win32 get thread priority */
-/* ReleaseSemaphore Win32 release semaphore */
-/* WaitForSingleObject Win32 wait on semaphore */
-/* */
-/* CALLED BY */
-/* */
-/* ThreadX components */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function is target processor specific. It is used to transfer */
+/* control from a thread back to the system. Only a minimal context */
+/* is saved since the compiler assumes temp registers are going to get */
+/* slicked by a function call anyway. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* _tx_win32_critical_section_release_all */
+/* Release critical section */
+/* ExitThread Win32 thread exit */
+/* GetCurrentThread Win32 get current thread */
+/* GetCurrentThreadId Win32 get current thread ID */
+/* GetThreadPriority Win32 get thread priority */
+/* ReleaseSemaphore Win32 release semaphore */
+/* WaitForSingleObject Win32 wait on semaphore */
+/* */
+/* CALLED BY */
+/* */
+/* ThreadX components */
/* */
/**************************************************************************/
VOID _tx_thread_system_return(VOID)
@@ -86,7 +81,7 @@ TX_THREAD *temp_thread_ptr;
HANDLE temp_run_semaphore;
UINT temp_thread_state;
HANDLE threadhandle;
-int threadpriority;
+int threadpriority;
DWORD threadid;
@@ -102,7 +97,7 @@ DWORD threadid;
/* First, determine if the thread was terminated. */
/* Pickup the priority of the current thread. */
- threadpriority = GetThreadPriority(threadhandle);
+ threadpriority = GetThreadPriority(threadhandle);
/* Pickup the ID of the current thread. */
threadid = GetCurrentThreadId();
@@ -110,21 +105,21 @@ DWORD threadid;
/* Pickup the current thread pointer. */
temp_thread_ptr = _tx_thread_current_ptr;
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
- /* This indicates the Win32 thread was actually terminated by ThreadX and is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX and is only
being allowed to run in order to cleanup its resources. */
-
+
/* Release critical section. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
-
+
/* Exit thread. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Determine if the time-slice is active. */
if (_tx_timer_time_slice)
@@ -181,19 +176,19 @@ DWORD threadid;
/* Pickup the current thread pointer. */
temp_thread_ptr = _tx_thread_current_ptr;
- /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
+ /* Determine if this is a thread (THREAD_PRIORITY_LOWEST) and it does not
match the current thread pointer. */
- if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
- ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
- {
+ if ((threadpriority == THREAD_PRIORITY_LOWEST) &&
+ ((!temp_thread_ptr) || (temp_thread_ptr -> tx_thread_win32_thread_id != threadid)))
+ {
/* Leave Win32 critical section. */
_tx_win32_critical_section_release_all(&_tx_win32_critical_section);
- /* This indicates the Win32 thread was actually terminated by ThreadX and is only
+ /* This indicates the Win32 thread was actually terminated by ThreadX and is only
being allowed to run in order to cleanup its resources. */
- ExitThread(0);
- }
+ ExitThread(0);
+ }
/* Now determine if the application thread last had interrupts disabled. */
diff --git a/ports/win32/vs_2019/src/tx_timer_interrupt.c b/ports/win32/vs_2019/src/tx_timer_interrupt.c
index 7830536d..a60ad144 100644
--- a/ports/win32/vs_2019/src/tx_timer_interrupt.c
+++ b/ports/win32/vs_2019/src/tx_timer_interrupt.c
@@ -1,18 +1,19 @@
/***************************************************************************
- * Copyright (c) 2024 Microsoft Corporation
- *
+ * Copyright (c) 2024 Microsoft Corporation
+ * Copyright (c) 2026-present 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.
- *
+ *
* SPDX-License-Identifier: MIT
**************************************************************************/
/**************************************************************************/
/**************************************************************************/
-/** */
-/** ThreadX Component */
+/** */
+/** ThreadX Component */
/** */
/** Timer */
/** */
@@ -29,48 +30,42 @@
#include "tx_thread.h"
-/**************************************************************************/
-/* */
-/* FUNCTION RELEASE */
-/* */
-/* _tx_timer_interrupt Win32/Visual */
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _tx_timer_interrupt Win32/Visual */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
-/* */
-/* This function processes the hardware timer interrupt. This */
-/* processing includes incrementing the system clock and checking for */
-/* time slice and/or timer expiration. If either is found, the */
-/* interrupt context save/restore functions are called along with the */
-/* expiration functions. */
-/* */
-/* INPUT */
-/* */
-/* None */
-/* */
-/* OUTPUT */
-/* */
-/* None */
-/* */
-/* CALLS */
-/* */
-/* _tx_thread_time_slice Time slice interrupted thread */
-/* _tx_timer_expiration_process Timer expiration processing */
-/* _tx_win32_critical_section_obtain Obtain critical section */
-/* _tx_win32_critical_section_release Release critical section */
-/* */
-/* CALLED BY */
-/* */
-/* interrupt vector */
-/* */
-/* RELEASE HISTORY */
-/* */
-/* DATE NAME DESCRIPTION */
/* */
-/* 09-30-2020 William E. Lamie Initial Version 6.1 */
+/* This function processes the hardware timer interrupt. This */
+/* processing includes incrementing the system clock and checking for */
+/* time slice and/or timer expiration. If either is found, the */
+/* interrupt context save/restore functions are called along with the */
+/* expiration functions. */
+/* */
+/* INPUT */
+/* */
+/* None */
+/* */
+/* OUTPUT */
+/* */
+/* None */
+/* */
+/* CALLS */
+/* */
+/* _tx_thread_time_slice Time slice interrupted thread */
+/* _tx_timer_expiration_process Timer expiration processing */
+/* _tx_win32_critical_section_obtain Obtain critical section */
+/* _tx_win32_critical_section_release Release critical section */
+/* */
+/* CALLED BY */
+/* */
+/* interrupt vector */
/* */
/**************************************************************************/
VOID _tx_timer_interrupt(VOID)