]> git.sur5r.net Git - freertos/commitdiff
Add critical section around xTaskCheckForTimeout() as the new queue code makes a...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 23 Mar 2008 16:00:51 +0000 (16:00 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sun, 23 Mar 2008 16:00:51 +0000 (16:00 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@254 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/tasks.c

index 94640ed85a810cd472e17eb583197aae85b22e09..68c927f295ed88a928f699292b7ef2b601b1382c 100644 (file)
@@ -323,7 +323,7 @@ register tskTCB *pxTCB;                                                                                                                                                                                             \
                /* Has the extremity of the task stack ever been written over? */                                                                                                                                                       \\r
                if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 )                                          \\r
                {                                                                                                                                                                                                                                                                                       \\r
-                       vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName );                                                                                                                                \\r
+                       vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName );                                                                                                \\r
                }                                                                                                                                                                                                                                                                                       \\r
        }\r
 \r
@@ -1560,36 +1560,40 @@ portBASE_TYPE xTaskCheckForTimeOut( xTimeOutType * const pxTimeOut, portTickType
 {\r
 portBASE_TYPE xReturn;\r
 \r
-       #if ( INCLUDE_vTaskSuspend == 1 )\r
-               /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
-               the maximum block time then the task should block indefinitely, and\r
-               therefore never time out. */\r
-               if( *pxTicksToWait == portMAX_DELAY )\r
+       portENTER_CRITICAL();\r
+       {\r
+               #if ( INCLUDE_vTaskSuspend == 1 )\r
+                       /* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
+                       the maximum block time then the task should block indefinitely, and\r
+                       therefore never time out. */\r
+                       if( *pxTicksToWait == portMAX_DELAY )\r
+                       {\r
+                               xReturn = pdFALSE;\r
+                       }\r
+                       else /* We are not blocking indefinitely, perform the checks below. */\r
+               #endif\r
+\r
+               if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xTickCount >= pxTimeOut->xTimeOnEntering ) )\r
                {\r
+                       /* The tick count is greater than the time at which vTaskSetTimeout()\r
+                       was called, but has also overflowed since vTaskSetTimeOut() was called.\r
+                       It must have wrapped all the way around and gone past us again. This\r
+                       passed since vTaskSetTimeout() was called. */\r
+                       xReturn = pdTRUE;\r
+               }\r
+               else if( ( xTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait )\r
+               {\r
+                       /* Not a genuine timeout. Adjust parameters for time remaining. */\r
+                       *pxTicksToWait -= ( xTickCount - pxTimeOut->xTimeOnEntering );\r
+                       vTaskSetTimeOutState( pxTimeOut );\r
                        xReturn = pdFALSE;\r
                }\r
-               else /* We are not blocking indefinitely, perform the checks below. */\r
-       #endif\r
-\r
-    if( ( xNumOfOverflows != pxTimeOut->xOverflowCount ) && ( xTickCount >= pxTimeOut->xTimeOnEntering ) )\r
-    {\r
-        /* The tick count is greater than the time at which vTaskSetTimeout()\r
-               was called, but has also overflowed since vTaskSetTimeOut() was called.\r
-        It must have wrapped all the way around and gone past us again. This\r
-        passed since vTaskSetTimeout() was called. */\r
-        xReturn = pdTRUE;\r
-    }\r
-    else if( ( xTickCount - pxTimeOut->xTimeOnEntering ) < *pxTicksToWait )\r
-    {\r
-        /* Not a genuine timeout. Adjust parameters for time remaining. */\r
-        *pxTicksToWait -= ( xTickCount - pxTimeOut->xTimeOnEntering );\r
-        vTaskSetTimeOutState( pxTimeOut );\r
-        xReturn = pdFALSE;\r
-    }\r
-    else\r
-    {\r
-        xReturn = pdTRUE;\r
-    }\r
+               else\r
+               {\r
+                       xReturn = pdTRUE;\r
+               }\r
+       }\r
+       portEXIT_CRITICAL();\r
 \r
     return xReturn;\r
 }\r