From 3944eef301c7bf178992f73e5a59f94a662f08f5 Mon Sep 17 00:00:00 2001 From: Ju1He1 <93189163+Ju1He1@users.noreply.github.com> Date: Sat, 11 Feb 2023 23:03:22 +0100 Subject: [PATCH 1/4] make port exitable --- portable/MSVC-MingW/port.c | 45 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index 67b79baa917..8de96de433b 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -160,7 +160,7 @@ TIMECAPS xTimeCaps; /* Just to prevent compiler warnings. */ ( void ) lpParameter; - for( ;; ) + while(pdTRUE == xPortRunning) { /* Wait until the timer expires and we can access the simulated interrupt variables. *NOTE* this is not a 'real time' way of generating tick @@ -176,33 +176,32 @@ TIMECAPS xTimeCaps; { Sleep( portTICK_PERIOD_MS ); } + if(pdTRUE == xPortRunning) + { + configASSERT( xPortRunning ); - configASSERT( xPortRunning ); - - /* Can't proceed if in a critical section as pvInterruptEventMutex won't - be available. */ - WaitForSingleObject( pvInterruptEventMutex, INFINITE ); + /* Can't proceed if in a critical section as pvInterruptEventMutex won't + be available. */ + WaitForSingleObject( pvInterruptEventMutex, INFINITE ); - /* The timer has expired, generate the simulated tick event. */ - ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK ); + /* The timer has expired, generate the simulated tick event. */ + ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK ); - /* The interrupt is now pending - notify the simulated interrupt - handler thread. Must be outside of a critical section to get here so - the handler thread can execute immediately pvInterruptEventMutex is - released. */ - configASSERT( ulCriticalNesting == 0UL ); - SetEvent( pvInterruptEvent ); + /* The interrupt is now pending - notify the simulated interrupt + handler thread. Must be outside of a critical section to get here so + the handler thread can execute immediately pvInterruptEventMutex is + released. */ + configASSERT( ulCriticalNesting == 0UL ); + SetEvent( pvInterruptEvent ); - /* Give back the mutex so the simulated interrupt handler unblocks - and can access the interrupt handler variables. */ - ReleaseMutex( pvInterruptEventMutex ); + /* Give back the mutex so the simulated interrupt handler unblocks + and can access the interrupt handler variables. */ + ReleaseMutex( pvInterruptEventMutex ); + } } - #ifdef __GNUC__ - /* Should never reach here - MingW complains if you leave this line out, - MSVC complains if you put it in. */ - return 0; - #endif + + return 0; } /*-----------------------------------------------------------*/ @@ -566,7 +565,7 @@ uint32_t ulErrorCode; void vPortEndScheduler( void ) { - exit( 0 ); + } /*-----------------------------------------------------------*/ From 912f7a48260238b183f73b6f9922e27908a20297 Mon Sep 17 00:00:00 2001 From: Ju1He1 <93189163+Ju1He1@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:46:52 +0100 Subject: [PATCH 2/4] correctly set xPortRunning to False --- portable/MSVC-MingW/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index 8de96de433b..6c96ae7aff8 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -565,7 +565,7 @@ uint32_t ulErrorCode; void vPortEndScheduler( void ) { - + xPortRunning = pdFALSE; } /*-----------------------------------------------------------*/ From aceea42319c78653201de5277232ab5475d5c560 Mon Sep 17 00:00:00 2001 From: Ju1He1 <93189163+Ju1He1@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:38:08 +0100 Subject: [PATCH 3/4] add suggestions from Review Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- portable/MSVC-MingW/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index 6c96ae7aff8..b1abdf0a75b 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -160,7 +160,7 @@ TIMECAPS xTimeCaps; /* Just to prevent compiler warnings. */ ( void ) lpParameter; - while(pdTRUE == xPortRunning) + while( xPortRunning == pdTRUE ) { /* Wait until the timer expires and we can access the simulated interrupt variables. *NOTE* this is not a 'real time' way of generating tick From 32361c946664fc0708b771eddb47b5f8556f79bd Mon Sep 17 00:00:00 2001 From: Ju1He1 <93189163+Ju1He1@users.noreply.github.com> Date: Mon, 13 Feb 2023 17:38:31 +0100 Subject: [PATCH 4/4] add suggestions from Review Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> --- portable/MSVC-MingW/port.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/portable/MSVC-MingW/port.c b/portable/MSVC-MingW/port.c index b1abdf0a75b..f39f0ecbb88 100644 --- a/portable/MSVC-MingW/port.c +++ b/portable/MSVC-MingW/port.c @@ -176,7 +176,8 @@ TIMECAPS xTimeCaps; { Sleep( portTICK_PERIOD_MS ); } - if(pdTRUE == xPortRunning) + + if( xPortRunning == pdTRUE ) { configASSERT( xPortRunning );