summaryrefslogtreecommitdiff
path: root/Source/tasks.c
diff options
context:
space:
mode:
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2006-10-22 20:28:16 +0000
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2006-10-22 20:28:16 +0000
commit2d522cab0a3d8ff644c39ef4bfcc333220838299 (patch)
tree1d59fe637477b4d603c359edc9dda6c72e65d4e6 /Source/tasks.c
parent5bc4e51425f5d2c778aa820da93e2728871e7229 (diff)
downloadfreertos-2d522cab0a3d8ff644c39ef4bfcc333220838299.tar.gz
freertos-2d522cab0a3d8ff644c39ef4bfcc333220838299.tar.bz2
freertos-2d522cab0a3d8ff644c39ef4bfcc333220838299.tar.xz
Changes from V4.1.2
+ Tasks that block with a timeout of portMAX_DELAY are now blocked indefinitely. Previously portMAX_DELAY was just the longest block time possible. git-svn-id: https://freertos.svn.sourceforge.net/svnroot/freertos/trunk@49 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'Source/tasks.c')
-rw-r--r--Source/tasks.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/Source/tasks.c b/Source/tasks.c
index 3d6f3175..9b722bf7 100644
--- a/Source/tasks.c
+++ b/Source/tasks.c
@@ -181,6 +181,12 @@ Changes from V4.0.5
+ Added utility functions and xOverflowCount variable to facilitate the
queue.c changes.
+
+Changes from V4.1.2
+
+ + Tasks that block with a timeout of portMAX_DELAY are now blocked
+ indefinitely. Previously portMAX_DELAY was just the longest block time
+ possible.
*/
#include <stdio.h>
@@ -1418,26 +1424,36 @@ portTickType xTimeToWake;
is the first to be woken by the event. */
vListInsert( ( xList * ) pxEventList, ( xListItem * ) &( pxCurrentTCB->xEventListItem ) );
- /* Calculate the time at which the task should be woken if the event does
- not occur. This may overflow but this doesn't matter. */
- xTimeToWake = xTickCount + xTicksToWait;
-
/* We must remove ourselves from the ready list before adding ourselves
to the blocked list as the same list item is used for both lists. We have
exclusive access to the ready lists as the scheduler is locked. */
vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
- listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );
-
- if( xTimeToWake < xTickCount )
+ if( xTicksToWait == portMAX_DELAY )
{
- /* Wake time has overflowed. Place this item in the overflow list. */
- vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
+ /* Add ourselves to the suspended task list instead of a delayed task
+ list to ensure we are not woken by a timing event. We will block
+ indefinitely. */
+ vListInsertEnd( ( xList * ) &xSuspendedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
}
else
{
- /* The wake time has not overflowed, so we can use the current block list. */
- vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
+ /* Calculate the time at which the task should be woken if the event does
+ not occur. This may overflow but this doesn't matter. */
+ xTimeToWake = xTickCount + xTicksToWait;
+
+ listSET_LIST_ITEM_VALUE( &( pxCurrentTCB->xGenericListItem ), xTimeToWake );
+
+ if( xTimeToWake < xTickCount )
+ {
+ /* Wake time has overflowed. Place this item in the overflow list. */
+ vListInsert( ( xList * ) pxOverflowDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
+ }
+ else
+ {
+ /* The wake time has not overflowed, so we can use the current block list. */
+ vListInsert( ( xList * ) pxDelayedTaskList, ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );
+ }
}
}
/*-----------------------------------------------------------*/