Skip to content

Commit 8252ede

Browse files
Ju1He1aggarg
Ju1He1
andauthored
Do not call exit() on MSVC Port when calling vPortEndScheduler (#624)
* make port exitable * correctly set xPortRunning to False * add suggestions from Review Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]> * add suggestions from Review Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]> --------- Co-authored-by: Gaurav-Aggarwal-AWS <[email protected]>
1 parent 050cf0d commit 8252ede

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

portable/MSVC-MingW/port.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ TIMECAPS xTimeCaps;
160160
/* Just to prevent compiler warnings. */
161161
( void ) lpParameter;
162162

163-
for( ;; )
163+
while( xPortRunning == pdTRUE )
164164
{
165165
/* Wait until the timer expires and we can access the simulated interrupt
166166
variables. *NOTE* this is not a 'real time' way of generating tick
@@ -177,32 +177,32 @@ TIMECAPS xTimeCaps;
177177
Sleep( portTICK_PERIOD_MS );
178178
}
179179

180-
configASSERT( xPortRunning );
180+
if( xPortRunning == pdTRUE )
181+
{
182+
configASSERT( xPortRunning );
181183

182-
/* Can't proceed if in a critical section as pvInterruptEventMutex won't
183-
be available. */
184-
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
184+
/* Can't proceed if in a critical section as pvInterruptEventMutex won't
185+
be available. */
186+
WaitForSingleObject( pvInterruptEventMutex, INFINITE );
185187

186-
/* The timer has expired, generate the simulated tick event. */
187-
ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK );
188+
/* The timer has expired, generate the simulated tick event. */
189+
ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK );
188190

189-
/* The interrupt is now pending - notify the simulated interrupt
190-
handler thread. Must be outside of a critical section to get here so
191-
the handler thread can execute immediately pvInterruptEventMutex is
192-
released. */
193-
configASSERT( ulCriticalNesting == 0UL );
194-
SetEvent( pvInterruptEvent );
191+
/* The interrupt is now pending - notify the simulated interrupt
192+
handler thread. Must be outside of a critical section to get here so
193+
the handler thread can execute immediately pvInterruptEventMutex is
194+
released. */
195+
configASSERT( ulCriticalNesting == 0UL );
196+
SetEvent( pvInterruptEvent );
195197

196-
/* Give back the mutex so the simulated interrupt handler unblocks
197-
and can access the interrupt handler variables. */
198-
ReleaseMutex( pvInterruptEventMutex );
198+
/* Give back the mutex so the simulated interrupt handler unblocks
199+
and can access the interrupt handler variables. */
200+
ReleaseMutex( pvInterruptEventMutex );
201+
}
199202
}
200203

201-
#ifdef __GNUC__
202-
/* Should never reach here - MingW complains if you leave this line out,
203-
MSVC complains if you put it in. */
204-
return 0;
205-
#endif
204+
205+
return 0;
206206
}
207207
/*-----------------------------------------------------------*/
208208

@@ -566,7 +566,7 @@ uint32_t ulErrorCode;
566566

567567
void vPortEndScheduler( void )
568568
{
569-
exit( 0 );
569+
xPortRunning = pdFALSE;
570570
}
571571
/*-----------------------------------------------------------*/
572572

0 commit comments

Comments
 (0)