]> git.sur5r.net Git - freertos/commitdiff
Replace the need for taskCHECK_READY_LIST() by instead making vListRemove() return...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 24 Sep 2012 12:05:35 +0000 (12:05 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 24 Sep 2012 12:05:35 +0000 (12:05 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1784 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/croutine.c
FreeRTOS/Source/include/list.h
FreeRTOS/Source/list.c
FreeRTOS/Source/tasks.c
FreeRTOS/Source/timers.c

index 0d62ca08334ac35f0300d87098434c37c106c311..7d51aedef0494769f8d83439df3beb6c3320c3fd 100644 (file)
@@ -203,7 +203,7 @@ portTickType xTimeToWake;
        /* We must remove ourselves from the ready list before adding\r
        ourselves to the blocked list as the same list item is used for\r
        both lists. */\r
-       vListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );\r
+       uxListRemove( ( xListItem * ) &( pxCurrentCoRoutine->xGenericListItem ) );\r
 \r
        /* The list item will be inserted in wake time order. */\r
        listSET_LIST_ITEM_VALUE( &( pxCurrentCoRoutine->xGenericListItem ), xTimeToWake );\r
@@ -243,11 +243,11 @@ static void prvCheckPendingReadyList( void )
                portDISABLE_INTERRUPTS();\r
                {       \r
                        pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( (&xPendingReadyCoRoutineList) );                   \r
-                       vListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
+                       uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
                }\r
                portENABLE_INTERRUPTS();\r
 \r
-               vListRemove( &( pxUnblockedCRCB->xGenericListItem ) );\r
+               uxListRemove( &( pxUnblockedCRCB->xGenericListItem ) );\r
                prvAddCoRoutineToReadyQueue( pxUnblockedCRCB ); \r
        }\r
 }\r
@@ -293,12 +293,12 @@ corCRCB *pxCRCB;
                                have been moved to the pending ready list and the following\r
                                line is still valid.  Also the pvContainer parameter will have\r
                                been set to NULL so the following lines are also valid. */\r
-                               vListRemove( &( pxCRCB->xGenericListItem ) );                                                                                   \r
+                               uxListRemove( &( pxCRCB->xGenericListItem ) );                                                                                  \r
 \r
                                /* Is the co-routine waiting on an event also? */                                                                                               \r
                                if( pxCRCB->xEventListItem.pvContainer )                                                                                                        \r
                                {                                                                                                                       \r
-                                       vListRemove( &( pxCRCB->xEventListItem ) );                                                                                     \r
+                                       uxListRemove( &( pxCRCB->xEventListItem ) );                                                                                    \r
                                }\r
                        }\r
                        portENABLE_INTERRUPTS();\r
@@ -370,7 +370,7 @@ signed portBASE_TYPE xReturn;
        event lists and the pending ready list.  This function assumes that a\r
        check has already been made to ensure pxEventList is not empty. */\r
        pxUnblockedCRCB = ( corCRCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
-       vListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
+       uxListRemove( &( pxUnblockedCRCB->xEventListItem ) );\r
        vListInsertEnd( ( xList * ) &( xPendingReadyCoRoutineList ), &( pxUnblockedCRCB->xEventListItem ) );\r
 \r
        if( pxUnblockedCRCB->uxPriority >= pxCurrentCoRoutine->uxPriority )\r
index 20ecd867c2974aa751e4f158e8420186be4444e2..08a36b69b9fc016a1319140ef9d0261050dbd2e8 100644 (file)
@@ -329,13 +329,16 @@ void vListInsertEnd( xList *pxList, xListItem *pxNewListItem );
  * Remove an item from a list.  The list item has a pointer to the list that\r
  * it is in, so only the list item need be passed into the function.\r
  *\r
- * @param vListRemove The item to be removed.  The item will remove itself from\r
+ * @param uxListRemove The item to be removed.  The item will remove itself from\r
  * the list pointed to by it's pxContainer parameter.\r
+ * \r
+ * @return The number of items that remain in the list after the list item has\r
+ * been removed.\r
  *\r
- * \page vListRemove vListRemove\r
+ * \page uxListRemove uxListRemove\r
  * \ingroup LinkedList\r
  */\r
-void vListRemove( xListItem *pxItemToRemove );\r
+unsigned portBASE_TYPE uxListRemove( xListItem *pxItemToRemove );\r
 \r
 #ifdef __cplusplus\r
 }\r
index 9ae5d86e49c433e0825c0fcfa18b819b674dd710..40e2bfd4049ddaa087a1eac85d42914b6661ba16 100644 (file)
@@ -180,7 +180,7 @@ portTickType xValueOfInsertion;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vListRemove( xListItem *pxItemToRemove )\r
+unsigned portBASE_TYPE uxListRemove( xListItem *pxItemToRemove )\r
 {\r
 xList * pxList;\r
 \r
@@ -199,6 +199,8 @@ xList * pxList;
 \r
        pxItemToRemove->pvContainer = NULL;\r
        ( pxList->uxNumberOfItems )--;\r
+       \r
+       return pxList->uxNumberOfItems;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 99a48c0c504e1ee17087982450c05026fffe3d7f..e04232b33b7b67a08553121c4959e8f4632151e4 100644 (file)
@@ -241,9 +241,9 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime                                            = ( portTickType )
 \r
        /*-----------------------------------------------------------*/\r
 \r
-       /* Define away taskCHECK_READY_LIST() as it is not required in this\r
+       /* Define away portRESET_READY_PRIORITY() as it is not required in this\r
        configuration. */\r
-       #define taskCHECK_READY_LIST( uxPriority )\r
+       #define portRESET_READY_PRIORITY( uxPriority, uxTopReadyPriority )\r
 \r
 #else /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
 \r
@@ -261,19 +261,6 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime                                           = ( portTickType )
                listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopPriority ] ) );                                                   \\r
        } /* taskSELECT_HIGHEST_PRIORITY_TASK() */\r
 \r
-       /*-----------------------------------------------------------*/\r
-\r
-       /* Let the port layer know if the ready list is empty so \r
-       taskSELECT_HIGHEST_PRIORITY_TASK() can function correctly. */\r
-       #define taskCHECK_READY_LIST( uxPriority )                                                                                                                                                      \\r
-       {                                                                                                                                                                                                                                       \\r
-               if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ ( uxPriority ) ] ) ) == 0 )                                                                  \\r
-               {                                                                                                                                                                                                                               \\r
-                       portRESET_READY_PRIORITY( ( uxPriority ), uxTopReadyPriority );                                                                                         \\r
-               }                                                                                                                                                                                                                               \\r
-       } /* taskCHECK_READY_LIST() */\r
-\r
-\r
 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
 \r
 /*\r
@@ -336,12 +323,12 @@ portTickType xItemValue;                                                                                                                          \
                                }                                                                                                                                               \\r
                                                                                                                                                                                \\r
                                /* It is time to remove the item from the Blocked state. */                             \\r
-                               vListRemove( &( pxTCB->xGenericListItem ) );                                                    \\r
+                               uxListRemove( &( pxTCB->xGenericListItem ) );                                                   \\r
                                                                                                                                                                                \\r
                                /* Is the task waiting on an event also? */                                                             \\r
                                if( pxTCB->xEventListItem.pvContainer != NULL )                                                 \\r
                                {                                                                                                                                               \\r
-                                       vListRemove( &( pxTCB->xEventListItem ) );                                                      \\r
+                                       uxListRemove( &( pxTCB->xEventListItem ) );                                                     \\r
                                }                                                                                                                                               \\r
                                prvAddTaskToReadyQueue( pxTCB );                                                                                \\r
                        }                                                                                                                                                       \\r
@@ -641,13 +628,15 @@ tskTCB * pxNewTCB;
                        This will stop the task from be scheduled.  The idle task will check\r
                        the termination list and free up any memory allocated by the\r
                        scheduler for the TCB and stack. */\r
-                       vListRemove( &( pxTCB->xGenericListItem ) );\r
-                       taskCHECK_READY_LIST( pxTCB->uxPriority );\r
+                       if( uxListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ) == 0 )\r
+                       {\r
+                               portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
+                       }\r
 \r
                        /* Is the task waiting on an event also? */\r
                        if( pxTCB->xEventListItem.pvContainer != NULL )\r
                        {\r
-                               vListRemove( &( pxTCB->xEventListItem ) );\r
+                               uxListRemove( &( pxTCB->xEventListItem ) );\r
                        }\r
 \r
                        vListInsertEnd( ( xList * ) &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) );\r
@@ -734,8 +723,11 @@ tskTCB * pxNewTCB;
                                /* We must remove ourselves from the ready list before adding\r
                                ourselves to the blocked list as the same list item is used for\r
                                both lists. */\r
-                               vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );\r
-                               taskCHECK_READY_LIST( pxCurrentTCB->uxPriority );\r
+                               if( uxListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ) == 0 )\r
+                               {\r
+                                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                               }\r
+\r
                                prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                        }\r
                }\r
@@ -781,8 +773,10 @@ tskTCB * pxNewTCB;
                                /* We must remove ourselves from the ready list before adding\r
                                ourselves to the blocked list as the same list item is used for\r
                                both lists. */\r
-                               vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );\r
-                               taskCHECK_READY_LIST( pxCurrentTCB->uxPriority );\r
+                               if( uxListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ) == 0 )\r
+                               {\r
+                                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+                               }\r
                                prvAddCurrentTaskToDelayedList( xTimeToWake );\r
                        }\r
                        xAlreadyYielded = xTaskResumeAll();\r
@@ -975,8 +969,10 @@ tskTCB * pxNewTCB;
                                        /* The task is currently in its ready list - remove before adding\r
                                        it to it's new ready list.  As we are in a critical section we\r
                                        can do this even if the scheduler is suspended. */\r
-                                       vListRemove( &( pxTCB->xGenericListItem ) );\r
-                                       taskCHECK_READY_LIST( uxCurrentPriority );\r
+                                       if( uxListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ) == 0 )\r
+                                       {\r
+                                               portRESET_READY_PRIORITY( uxCurrentPriority, uxTopReadyPriority );\r
+                                       }\r
                                        prvAddTaskToReadyQueue( pxTCB );\r
                                }\r
 \r
@@ -1013,13 +1009,15 @@ tskTCB * pxNewTCB;
                        traceTASK_SUSPEND( pxTCB );\r
 \r
                        /* Remove task from the ready/delayed list and place in the     suspended list. */\r
-                       vListRemove( &( pxTCB->xGenericListItem ) );\r
-                       taskCHECK_READY_LIST( pxTCB->uxPriority );\r
+                       if( uxListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ) == 0 )\r
+                       {\r
+                               portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
+                       }\r
 \r
                        /* Is the task waiting on an event also? */\r
                        if( pxTCB->xEventListItem.pvContainer != NULL )\r
                        {\r
-                               vListRemove( &( pxTCB->xEventListItem ) );\r
+                               uxListRemove( &( pxTCB->xEventListItem ) );\r
                        }\r
 \r
                        vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );\r
@@ -1116,7 +1114,7 @@ tskTCB * pxNewTCB;
 \r
                                        /* As we are in a critical section we can access the ready\r
                                        lists even if the scheduler is suspended. */\r
-                                       vListRemove(  &( pxTCB->xGenericListItem ) );\r
+                                       uxListRemove(  &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyQueue( pxTCB );\r
 \r
                                        /* We may have just resumed a higher priority task. */\r
@@ -1157,7 +1155,7 @@ tskTCB * pxNewTCB;
                                if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
                                {\r
                                        xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
-                                       vListRemove(  &( pxTCB->xGenericListItem ) );\r
+                                       uxListRemove(  &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyQueue( pxTCB );\r
                                }\r
                                else\r
@@ -1297,8 +1295,8 @@ signed portBASE_TYPE xAlreadyYielded = pdFALSE;
                                while( listLIST_IS_EMPTY( ( xList * ) &xPendingReadyList ) == pdFALSE )\r
                                {\r
                                        pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY(  ( ( xList * ) &xPendingReadyList ) );\r
-                                       vListRemove( &( pxTCB->xEventListItem ) );\r
-                                       vListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       uxListRemove( &( pxTCB->xEventListItem ) );\r
+                                       uxListRemove( &( pxTCB->xGenericListItem ) );\r
                                        prvAddTaskToReadyQueue( pxTCB );\r
 \r
                                        /* If we have moved a task that has a priority higher than\r
@@ -1782,8 +1780,10 @@ portTickType xTimeToWake;
        /* We must remove ourselves from the ready list before adding ourselves\r
        to the blocked list as the same list item is used for both lists.  We have\r
        exclusive access to the ready lists as the scheduler is locked. */\r
-       vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );\r
-       taskCHECK_READY_LIST( pxCurrentTCB->uxPriority );\r
+       if( uxListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ) == 0 )\r
+       {\r
+               portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+       }\r
 \r
        #if ( INCLUDE_vTaskSuspend == 1 )\r
        {\r
@@ -1836,8 +1836,10 @@ portTickType xTimeToWake;
                /* We must remove this task from the ready list before adding it to the\r
                blocked list as the same list item is used for both lists.  This\r
                function is called form a critical section. */\r
-               vListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) );\r
-               taskCHECK_READY_LIST( pxCurrentTCB->uxPriority );\r
+               if( uxListRemove( ( xListItem * ) &( pxCurrentTCB->xGenericListItem ) ) == 0 )\r
+               {\r
+                       portRESET_READY_PRIORITY( pxCurrentTCB->uxPriority, uxTopReadyPriority );\r
+               }\r
 \r
                /* Calculate the time at which the task should be woken if the event does\r
                not occur.  This may overflow but this doesn't matter. */\r
@@ -1868,11 +1870,11 @@ portBASE_TYPE xReturn;
        pxEventList is not empty. */\r
        pxUnblockedTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( pxEventList );\r
        configASSERT( pxUnblockedTCB );\r
-       vListRemove( &( pxUnblockedTCB->xEventListItem ) );\r
+       uxListRemove( &( pxUnblockedTCB->xEventListItem ) );\r
 \r
        if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
        {\r
-               vListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
+               uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
                prvAddTaskToReadyQueue( pxUnblockedTCB );\r
        }\r
        else\r
@@ -2209,7 +2211,7 @@ static void prvCheckTasksWaitingTermination( void )
                                taskENTER_CRITICAL();\r
                                {\r
                                        pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) );\r
-                                       vListRemove( &( pxTCB->xGenericListItem ) );\r
+                                       uxListRemove( &( pxTCB->xGenericListItem ) );\r
                                        --uxCurrentNumberOfTasks;\r
                                        --uxTasksDeleted;\r
                                }\r
@@ -2517,8 +2519,10 @@ tskTCB *pxNewTCB;
                                be moved in to a new list. */\r
                                if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )\r
                                {\r
-                                       vListRemove( &( pxTCB->xGenericListItem ) );\r
-                                       taskCHECK_READY_LIST( pxTCB->uxPriority );\r
+                                       if( uxListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ) == 0 )\r
+                                       {\r
+                                               portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
+                                       }\r
 \r
                                        /* Inherit the priority before being moved into the new list. */\r
                                        pxTCB->uxPriority = pxCurrentTCB->uxPriority;\r
@@ -2550,8 +2554,10 @@ tskTCB *pxNewTCB;
                        {\r
                                /* We must be the running task to be able to give the mutex back.\r
                                Remove ourselves from the ready list we currently appear in. */\r
-                               vListRemove( &( pxTCB->xGenericListItem ) );\r
-                               taskCHECK_READY_LIST( pxTCB->uxPriority );\r
+                               if( uxListRemove( ( xListItem * ) &( pxTCB->xGenericListItem ) ) == 0 )\r
+                               {\r
+                                       portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
+                               }\r
 \r
                                /* Disinherit the priority before adding the task into the new\r
                                ready list. */\r
index 0be2942771cc72b882c99730bdcadaedaa03fcc0..ef80cd2dda52d4c3bd75c35c53e66e0af07a6aa4 100644 (file)
@@ -312,7 +312,7 @@ portBASE_TYPE xResult;
        /* Remove the timer from the list of active timers.  A check has already\r
        been performed to ensure the list is not empty. */\r
        pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
-       vListRemove( &( pxTimer->xTimerListItem ) );\r
+       uxListRemove( &( pxTimer->xTimerListItem ) );\r
        traceTIMER_EXPIRED( pxTimer );\r
 \r
        /* If the timer is an auto reload timer then calculate the next\r
@@ -526,7 +526,7 @@ portTickType xTimeNow;
                        if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE )\r
                        {\r
                                /* The timer is in a list, remove it. */\r
-                               vListRemove( &( pxTimer->xTimerListItem ) );\r
+                               uxListRemove( &( pxTimer->xTimerListItem ) );\r
                        }\r
                }\r
 \r
@@ -596,7 +596,7 @@ portBASE_TYPE xResult;
 \r
                /* Remove the timer from the list. */\r
                pxTimer = ( xTIMER * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );\r
-               vListRemove( &( pxTimer->xTimerListItem ) );\r
+               uxListRemove( &( pxTimer->xTimerListItem ) );\r
 \r
                /* Execute its callback, then send a command to restart the timer if\r
                it is an auto-reload timer.  It cannot be restarted here as the lists\r