]> git.sur5r.net Git - freertos/commitdiff
Remove the critical sections as not all ports can yield from within critical sections.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 19 May 2008 19:19:25 +0000 (19:19 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 19 May 2008 19:19:25 +0000 (19:19 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@363 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/Common/Minimal/blocktim.c

index e4f3cf38f3858758c3bf6c641aca0daac950fe86..9d28d1376453ee3f730303d8a1ecb87a2f9feee5 100644 (file)
@@ -69,7 +69,7 @@
 #define bktQUEUE_LENGTH                                ( 5 )\r
 #define bktSHORT_WAIT                          ( ( ( portTickType ) 20 ) / portTICK_RATE_MS )\r
 #define bktPRIMARY_BLOCK_TIME          ( 10 )\r
-#define bktALLOWABLE_MARGIN                    ( 12 )\r
+#define bktALLOWABLE_MARGIN                    ( 15 )\r
 #define bktTIME_TO_BLOCK                       ( 175 )\r
 #define bktDONT_BLOCK                          ( ( portTickType ) 0 )\r
 #define bktRUN_INDICATOR                       ( ( unsigned portBASE_TYPE ) 0x55 )\r
@@ -126,23 +126,17 @@ portTickType xTimeToBlock, xBlockedTime;
                        time.  When we wake, ensure the delta in time is as expected. */\r
                        xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem;\r
 \r
-                       /* A critical section is used to minimise the jitter in the time\r
-                       measurements. */\r
-                       portENTER_CRITICAL();\r
+                       xTimeWhenBlocking = xTaskGetTickCount();\r
+                       \r
+                       /* We should unblock after xTimeToBlock having not received\r
+                       anything on the queue. */\r
+                       if( xQueueReceive( xTestQueue, &xData, xTimeToBlock ) != errQUEUE_EMPTY )\r
                        {\r
-                               xTimeWhenBlocking = xTaskGetTickCount();\r
-                               \r
-                               /* We should unblock after xTimeToBlock having not received\r
-                               anything on the queue. */\r
-                               if( xQueueReceive( xTestQueue, &xData, xTimeToBlock ) != errQUEUE_EMPTY )\r
-                               {\r
-                                       xErrorOccurred = pdTRUE;\r
-                               }\r
-\r
-                               /* How long were we blocked for? */\r
-                               xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
+                               xErrorOccurred = pdTRUE;\r
                        }\r
-                       portEXIT_CRITICAL();\r
+\r
+                       /* How long were we blocked for? */\r
+                       xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
 \r
                        if( xBlockedTime < xTimeToBlock )\r
                        {\r
@@ -183,21 +177,17 @@ portTickType xTimeToBlock, xBlockedTime;
                        time.  When we wake, ensure the delta in time is as expected. */\r
                        xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem;\r
 \r
-                       portENTER_CRITICAL();\r
+                       xTimeWhenBlocking = xTaskGetTickCount();\r
+                       \r
+                       /* We should unblock after xTimeToBlock having not received\r
+                       anything on the queue. */\r
+                       if( xQueueSend( xTestQueue, &xItem, xTimeToBlock ) != errQUEUE_FULL )\r
                        {\r
-                               xTimeWhenBlocking = xTaskGetTickCount();\r
-                               \r
-                               /* We should unblock after xTimeToBlock having not received\r
-                               anything on the queue. */\r
-                               if( xQueueSend( xTestQueue, &xItem, xTimeToBlock ) != errQUEUE_FULL )\r
-                               {\r
-                                       xErrorOccurred = pdTRUE;\r
-                               }\r
-\r
-                               /* How long were we blocked for? */\r
-                               xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
+                               xErrorOccurred = pdTRUE;\r
                        }\r
-                       portEXIT_CRITICAL();\r
+\r
+                       /* How long were we blocked for? */\r
+                       xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
 \r
                        if( xBlockedTime < xTimeToBlock )\r
                        {\r
@@ -388,23 +378,19 @@ portBASE_TYPE xData;
                The first thing we do is attempt to read from the queue.  It should be\r
                full so we block.  Note the time before we block so we can check the\r
                wake time is as per that expected. */\r
-               portENTER_CRITICAL();\r
+               xTimeWhenBlocking = xTaskGetTickCount();\r
+               \r
+               /* We should unblock after bktTIME_TO_BLOCK having not received\r
+               anything on the queue. */\r
+               xData = 0;\r
+               xRunIndicator = bktRUN_INDICATOR;\r
+               if( xQueueSend( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL )\r
                {\r
-                       xTimeWhenBlocking = xTaskGetTickCount();\r
-                       \r
-                       /* We should unblock after bktTIME_TO_BLOCK having not received\r
-                       anything on the queue. */\r
-                       xData = 0;\r
-                       xRunIndicator = bktRUN_INDICATOR;\r
-                       if( xQueueSend( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL )\r
-                       {\r
-                               xErrorOccurred = pdTRUE;\r
-                       }\r
-\r
-                       /* How long were we inside the send function? */\r
-                       xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
+                       xErrorOccurred = pdTRUE;\r
                }\r
-               portEXIT_CRITICAL();\r
+\r
+               /* How long were we inside the send function? */\r
+               xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
 \r
                /* We should not have blocked for less time than bktTIME_TO_BLOCK. */\r
                if( xBlockedTime < bktTIME_TO_BLOCK )\r
@@ -428,21 +414,17 @@ portBASE_TYPE xData;
         Test 4\r
 \r
                As per test three, but with the send and receive reversed. */\r
-               portENTER_CRITICAL();\r
+               xTimeWhenBlocking = xTaskGetTickCount();\r
+               \r
+               /* We should unblock after bktTIME_TO_BLOCK having not received\r
+               anything on the queue. */\r
+               xRunIndicator = bktRUN_INDICATOR;\r
+               if( xQueueReceive( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_EMPTY )\r
                {\r
-                       xTimeWhenBlocking = xTaskGetTickCount();\r
-                       \r
-                       /* We should unblock after bktTIME_TO_BLOCK having not received\r
-                       anything on the queue. */\r
-                       xRunIndicator = bktRUN_INDICATOR;\r
-                       if( xQueueReceive( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_EMPTY )\r
-                       {\r
-                               xErrorOccurred = pdTRUE;\r
-                       }\r
-\r
-                       xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
+                       xErrorOccurred = pdTRUE;\r
                }\r
-               portEXIT_CRITICAL();\r
+\r
+               xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking;\r
 \r
                /* We should not have blocked for less time than bktTIME_TO_BLOCK. */\r
                if( xBlockedTime < bktTIME_TO_BLOCK )\r