diff --git a/Source/portable/MSVC-MingW/port.c b/Source/portable/MSVC-MingW/port.c index 35f3c95c93..f89b2d0818 100644 --- a/Source/portable/MSVC-MingW/port.c +++ b/Source/portable/MSVC-MingW/port.c @@ -532,4 +532,19 @@ long lMutexNeedsReleasing; ReleaseMutex( pvInterruptEventMutex ); } } +/*-----------------------------------------------------------*/ + +void vPortCheckCorrectThreadIsRunning( void ) +{ +xThreadState *pxThreadState = ( xThreadState * ) *( ( unsigned long * ) pxCurrentTCB ); + + /* When switching threads, Windows does not always seem to run the selected + thread immediately. This function can be called to check if the thread + that is currently running is the thread that is responsible for executing + the task selected by the real time scheduler. */ + if( GetCurrentThread() != pxThreadState->pvThread ) + { + SwitchToThread(); + } +}