]> git.sur5r.net Git - freertos/commitdiff
Changed vPortCheckCorrectThreadIsRunning() in the Win32 port layer to use the Win32...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 21 Nov 2010 14:06:23 +0000 (14:06 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 21 Nov 2010 14:06:23 +0000 (14:06 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1151 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/MSVC-MingW/port.c

index f89b2d0818fdfb0e77b37e6bacf4aab81730c0a1..5446325c91456536d39b459e8a97bcbea98e19b4 100644 (file)
@@ -88,7 +88,12 @@ typedef struct
        long lWaitingInterruptAck;                      \r
 \r
        /* Handle of the thread that executes the task. */\r
-       void * pvThread;                                        \r
+       void *pvThread;\r
+\r
+       /* Used to check that the thread that is supposed to be running in indeed\r
+       the thread that is running. */\r
+       unsigned long ulThreadId;\r
+\r
 } xThreadState;\r
 \r
 /* Pseudo interrupts waiting to be processed.  This is a bit mask where each\r
@@ -181,7 +186,7 @@ xThreadState *pxThreadState = NULL;
        pxThreadState = ( xThreadState * ) ( pxTopOfStack - sizeof( xThreadState ) );\r
 \r
        /* Create the thread itself. */\r
-       pxThreadState->pvThread = ( void * ) CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE ) pxCode, pvParameters, CREATE_SUSPENDED, NULL );\r
+       pxThreadState->pvThread = CreateThread( NULL, 0, ( LPTHREAD_START_ROUTINE ) pxCode, pvParameters, CREATE_SUSPENDED, &( pxThreadState->ulThreadId ) );\r
        SetThreadPriorityBoost( pxThreadState->pvThread, TRUE );\r
        pxThreadState->lWaitingInterruptAck = pdFALSE;\r
        SetThreadPriority( pxThreadState->pvThread, THREAD_PRIORITY_IDLE );\r
@@ -536,15 +541,20 @@ long lMutexNeedsReleasing;
 \r
 void vPortCheckCorrectThreadIsRunning( void )\r
 {\r
-xThreadState *pxThreadState = ( xThreadState * ) *( ( unsigned long * ) pxCurrentTCB );\r
+xThreadState *pxThreadState;\r
 \r
        /* When switching threads, Windows does not always seem to run the selected\r
        thread immediately.  This function can be called to check if the thread\r
        that is currently running is the thread that is responsible for executing\r
        the task selected by the real time scheduler. */\r
-       if( GetCurrentThread() != pxThreadState->pvThread )\r
+       if( xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED )\r
        {\r
-               SwitchToThread();\r
+               pxThreadState = ( xThreadState * ) *( ( unsigned long * ) pxCurrentTCB );\r
+\r
+               if( GetCurrentThreadId() != pxThreadState->ulThreadId )\r
+               {\r
+                       SwitchToThread();\r
+               }\r
        }\r
 }\r
 \r