Skip to content

Commit 9b679c3

Browse files
authored
Fix comments in list.h and clarify list usage in xTaskRemoveFromEventList (#289)
* Change instances of "descending" to "ascending" to match implementation. * Uncrustify * Clarify list usage in xTaskRemoveFromEventList
1 parent 9efe10b commit 9b679c3

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

include/list.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* list_ts can only store pointers to list_item_ts. Each ListItem_t contains a
3333
* numeric value (xItemValue). Most of the time the lists are sorted in
34-
* descending item value order.
34+
* ascending item value order.
3535
*
3636
* Lists are created already containing one list item. The value of this
3737
* item is the maximum possible that can be stored, it is therefore always at
@@ -141,19 +141,19 @@
141141
struct xLIST;
142142
struct xLIST_ITEM
143143
{
144-
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
145-
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */
146-
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */
147-
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
148-
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
149-
struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */
150-
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
144+
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
145+
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in ascending order. */
146+
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */
147+
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
148+
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
149+
struct xLIST * configLIST_VOLATILE pxContainer; /*< Pointer to the list in which this list item is placed (if any). */
150+
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
151151
};
152-
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
152+
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
153153

154154
struct xMINI_LIST_ITEM
155155
{
156-
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
156+
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
157157
configLIST_VOLATILE TickType_t xItemValue;
158158
struct xLIST_ITEM * configLIST_VOLATILE pxNext;
159159
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;
@@ -165,11 +165,11 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t;
165165
*/
166166
typedef struct xLIST
167167
{
168-
listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
168+
listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
169169
volatile UBaseType_t uxNumberOfItems;
170-
ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
171-
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
172-
listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
170+
ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
171+
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
172+
listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
173173
} List_t;
174174

175175
/*
@@ -192,7 +192,7 @@ typedef struct xLIST
192192

193193
/*
194194
* Access macro to set the value of the list item. In most cases the value is
195-
* used to sort the list in descending order.
195+
* used to sort the list in ascending order.
196196
*
197197
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
198198
* \ingroup LinkedList
@@ -359,7 +359,7 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION;
359359

360360
/*
361361
* Insert a list item into a list. The item will be inserted into the list in
362-
* a position determined by its item value (descending item value order).
362+
* a position determined by its item value (ascending item value order).
363363
*
364364
* @param pxList The list into which the item is to be inserted.
365365
*

tasks.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ typedef struct tskTaskControlBlock /* The old naming convention is used to
295295
#endif
296296

297297
#if ( configUSE_NEWLIB_REENTRANT == 1 )
298-
299298
/* Allocate a Newlib reent structure that is specific to this task.
300299
* Note Newlib support has been included by popular demand, but is not
301300
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
@@ -3093,8 +3092,15 @@ void vTaskPlaceOnEventList( List_t * const pxEventList,
30933092

30943093
/* Place the event list item of the TCB in the appropriate event list.
30953094
* This is placed in the list in priority order so the highest priority task
3096-
* is the first to be woken by the event. The queue that contains the event
3097-
* list is locked, preventing simultaneous access from interrupts. */
3095+
* is the first to be woken by the event.
3096+
*
3097+
* Note: Lists are sorted in ascending order by ListItem_t.xItemValue.
3098+
* Normally, the xItemValue of a TCB's ListItem_t members is:
3099+
* xItemValue = ( configMAX_PRIORITIES - uxPriority )
3100+
* Therefore, the event list is sorted in descending priority order.
3101+
*
3102+
* The queue that contains the event list is locked, preventing
3103+
* simultaneous access from interrupts. */
30983104
vListInsert( pxEventList, &( pxCurrentTCB->xEventListItem ) );
30993105

31003106
prvAddCurrentTaskToDelayedList( xTicksToWait, pdTRUE );

0 commit comments

Comments
 (0)