From: RichardBarry Date: Sun, 21 Nov 2010 11:34:12 +0000 (+0000) Subject: Added vPortCheckCorrectThreadIsRunning() function to the Win32 port layer to trap... X-Git-Tag: V6.1.1~108 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=815d476db24a33da0c5bf47d6cd71cb7c4fc8890;p=freertos Added vPortCheckCorrectThreadIsRunning() function to the Win32 port layer to trap when Windows is not running the correct thread and try and catch it. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1149 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Source/portable/MSVC-MingW/port.c b/Source/portable/MSVC-MingW/port.c index 35f3c95c9..f89b2d081 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(); + } +}