]> git.sur5r.net Git - freertos/commitdiff
Improve efficiency and behaviour of vListInsertEnd().
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 26 Jun 2013 08:58:01 +0000 (08:58 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 26 Jun 2013 08:58:01 +0000 (08:58 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1951 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/list.c
FreeRTOS/Source/tasks.c

index c916a39457594a3030d3b3d9afb3e4d659274403..1e6a7486d6c955f111198fda86490329065a8542 100644 (file)
@@ -114,15 +114,13 @@ volatile xListItem * pxIndex;
 \r
        /* Insert a new list item into pxList, but rather than sort the list,\r
        makes the new list item the last item to be removed by a call to\r
-       pvListGetOwnerOfNextEntry.  This means it has to be the item pointed to by\r
-       the pxIndex member. */\r
+       pvListGetOwnerOfNextEntry. */\r
        pxIndex = pxList->pxIndex;\r
 \r
-       pxNewListItem->pxNext = pxIndex->pxNext;\r
-       pxNewListItem->pxPrevious = pxList->pxIndex;\r
-       pxIndex->pxNext->pxPrevious = ( volatile xListItem * ) pxNewListItem;\r
-       pxIndex->pxNext = ( volatile xListItem * ) pxNewListItem;\r
-       pxList->pxIndex = ( volatile xListItem * ) pxNewListItem;\r
+       pxNewListItem->pxNext = pxIndex;\r
+       pxNewListItem->pxPrevious = pxIndex->pxPrevious;\r
+       pxIndex->pxPrevious->pxNext = ( volatile xListItem * ) pxNewListItem;\r
+       pxIndex->pxPrevious = ( volatile xListItem * ) pxNewListItem;   \r
 \r
        /* Remember which list the item is in. */\r
        pxNewListItem->pvContainer = ( void * ) pxList;\r
index bc0a6e01a936901ec66e543eb422d65c9e8d2d63..e4e42c5a302c0015bbdbdc05baa54bb67c0c7e54 100644 (file)
@@ -166,7 +166,7 @@ PRIVILEGED_DATA static xList xDelayedTaskList1;                                                     /*< Delayed tasks. */
 PRIVILEGED_DATA static xList xDelayedTaskList2;                                                        /*< Delayed tasks (two lists are used - one for delays that have overflowed the current tick count. */\r
 PRIVILEGED_DATA static xList * volatile pxDelayedTaskList ;                            /*< Points to the delayed task list currently being used. */\r
 PRIVILEGED_DATA static xList * volatile pxOverflowDelayedTaskList;             /*< Points to the delayed task list currently being used to hold tasks that have overflowed the current tick count. */\r
-PRIVILEGED_DATA static xList xPendingReadyList;                                                        /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready queue when the scheduler is resumed. */\r
+PRIVILEGED_DATA static xList xPendingReadyList;                                                        /*< Tasks that have been readied while the scheduler was suspended.  They will be moved to the ready list when the scheduler is resumed. */\r
 \r
 #if ( INCLUDE_vTaskDelete == 1 )\r
 \r
@@ -341,13 +341,10 @@ count overflows. */
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * Place the task represented by pxTCB into the appropriate ready queue for\r
- * the task.  It is inserted at the end of the list.  One quirk of this is\r
- * that if the task being inserted is at the same priority as the currently\r
- * executing task, then it will only be rescheduled after the currently\r
- * executing task has been rescheduled.\r
+ * Place the task represented by pxTCB into the appropriate ready list for\r
+ * the task.  It is inserted at the end of the list.\r
  */\r
-#define prvAddTaskToReadyQueue( pxTCB )                                                                                                                                                                \\r
+#define prvAddTaskToReadyList( pxTCB )                                                                                                                                                         \\r
        traceMOVED_TASK_TO_READY_STATE( pxTCB )                                                                                                                                                 \\r
        taskRECORD_READY_PRIORITY( ( pxTCB )->uxPriority );                                                                                                                             \\r
        vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )\r
@@ -548,8 +545,8 @@ tskTCB * pxNewTCB;
                        *pxCreatedTask = ( xTaskHandle ) pxNewTCB;\r
                }\r
 \r
-               /* We are going to manipulate the task queues to add this task to a\r
-               ready list, so must make sure no interrupts occur. */\r
+               /* Ensure interrupts don't access the task lists while they are being\r
+               updated. */\r
                taskENTER_CRITICAL();\r
                {\r
                        uxCurrentNumberOfTasks++;\r
@@ -598,7 +595,7 @@ tskTCB * pxNewTCB;
                        #endif /* configUSE_TRACE_FACILITY */\r
                        traceTASK_CREATE( pxNewTCB );\r
 \r
-                       prvAddTaskToReadyQueue( pxNewTCB );\r
+                       prvAddTaskToReadyList( pxNewTCB );\r
 \r
                        xReturn = pdPASS;\r
                        portSETUP_TCB( pxNewTCB );\r
@@ -996,7 +993,7 @@ tskTCB * pxNewTCB;
                                        {\r
                                                taskRESET_READY_PRIORITY( uxPriorityUsedOnEntry );\r
                                        }\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
                                }\r
 \r
                                if( xYieldRequired == pdTRUE )\r
@@ -1142,7 +1139,7 @@ tskTCB * pxNewTCB;
                                        /* As we are in a critical section we can access the ready\r
                                        lists even if the scheduler is suspended. */\r
                                        uxListRemove(  &( pxTCB->xGenericListItem ) );\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
 \r
                                        /* We may have just resumed a higher priority task. */\r
                                        if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )\r
@@ -1183,7 +1180,7 @@ tskTCB * pxNewTCB;
                                {\r
                                        xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );\r
                                        uxListRemove(  &( pxTCB->xGenericListItem ) );\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
                                }\r
                                else\r
                                {\r
@@ -1348,7 +1345,7 @@ portBASE_TYPE xYieldRequired = pdFALSE;
                                        pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY(  ( ( xList * ) &xPendingReadyList ) );\r
                                        uxListRemove( &( pxTCB->xEventListItem ) );\r
                                        uxListRemove( &( pxTCB->xGenericListItem ) );\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
 \r
                                        /* If we have moved a task that has a priority higher than\r
                                        the current task then we should yield. */\r
@@ -1673,7 +1670,7 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
 \r
                                        /* Place the unblocked task into the appropriate ready\r
                                        list. */\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
 \r
                                        /* A task being unblocked cannot cause an immediate context\r
                                        switch if preemption is turned off. */\r
@@ -1983,7 +1980,7 @@ portBASE_TYPE xReturn;
        if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )\r
        {\r
                uxListRemove( &( pxUnblockedTCB->xGenericListItem ) );\r
-               prvAddTaskToReadyQueue( pxUnblockedTCB );\r
+               prvAddTaskToReadyList( pxUnblockedTCB );\r
        }\r
        else\r
        {\r
@@ -2711,7 +2708,7 @@ tskTCB *pxNewTCB;
 \r
                                        /* Inherit the priority before being moved into the new list. */\r
                                        pxTCB->uxPriority = pxCurrentTCB->uxPriority;\r
-                                       prvAddTaskToReadyQueue( pxTCB );\r
+                                       prvAddTaskToReadyList( pxTCB );\r
                                }\r
                                else\r
                                {\r
@@ -2749,7 +2746,7 @@ tskTCB *pxNewTCB;
                                traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
                                pxTCB->uxPriority = pxTCB->uxBasePriority;\r
                                listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority );\r
-                               prvAddTaskToReadyQueue( pxTCB );\r
+                               prvAddTaskToReadyList( pxTCB );\r
                        }\r
                }\r
        }\r