Enable MSVC Port to leave the prvProcessSimulatedInterrupts loop when scheduler is stopped (#728)

* allow to leave loop

* add missing brace

* Code review suggestions

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
Ju1He1 2023-07-31 11:35:17 +02:00 committed by GitHub
parent 8d80cf697a
commit 225bace85c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -340,6 +340,9 @@ SYSTEM_INFO xSystemInfo;
/* Start the first task. */ /* Start the first task. */
ResumeThread( pxThreadState->pvThread ); ResumeThread( pxThreadState->pvThread );
/* The scheduler is now running. */
xPortRunning = pdTRUE;
/* Handle all simulated interrupts - including yield requests and /* Handle all simulated interrupts - including yield requests and
simulated ticks. */ simulated ticks. */
prvProcessSimulatedInterrupts(); prvProcessSimulatedInterrupts();
@ -376,6 +379,8 @@ uint32_t ulSwitchRequired, i;
ThreadState_t *pxThreadState; ThreadState_t *pxThreadState;
void *pvObjectList[ 2 ]; void *pvObjectList[ 2 ];
CONTEXT xContext; CONTEXT xContext;
DWORD xWinApiResult;
const DWORD xTimeoutMilliseconds = 1000;
/* Going to block on the mutex that ensured exclusive access to the simulated /* Going to block on the mutex that ensured exclusive access to the simulated
interrupt objects, and the event that signals that a simulated interrupt interrupt objects, and the event that signals that a simulated interrupt
@ -388,13 +393,16 @@ CONTEXT xContext;
ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK ); ulPendingInterrupts |= ( 1 << portINTERRUPT_TICK );
SetEvent( pvInterruptEvent ); SetEvent( pvInterruptEvent );
xPortRunning = pdTRUE; while( xPortRunning == pdTRUE )
for(;;)
{ {
xInsideInterrupt = pdFALSE; xInsideInterrupt = pdFALSE;
WaitForMultipleObjects( sizeof( pvObjectList ) / sizeof( void * ), pvObjectList, TRUE, INFINITE );
/* Wait with timeout so that we can exit from this loop when
* the scheduler is stopped by calling vPortEndScheduler. */
xWinApiResult = WaitForMultipleObjects( sizeof( pvObjectList ) / sizeof( void * ), pvObjectList, TRUE, xTimeoutMilliseconds );
if( xWinApiResult != WAIT_TIMEOUT )
{
/* Cannot be in a critical section to get here. Tasks that exit a /* Cannot be in a critical section to get here. Tasks that exit a
critical section will block on a yield mutex to wait for an interrupt to critical section will block on a yield mutex to wait for an interrupt to
process if an interrupt was set pending while the task was inside the process if an interrupt was set pending while the task was inside the
@ -489,6 +497,7 @@ CONTEXT xContext;
ReleaseMutex( pvInterruptEventMutex ); ReleaseMutex( pvInterruptEventMutex );
} }
} }
}
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vPortDeleteThread( void *pvTaskToDelete ) void vPortDeleteThread( void *pvTaskToDelete )