From fd85f367c3e9d60966872e0247dde28d9f7784f3 Mon Sep 17 00:00:00 2001 From: David Chalco Date: Wed, 25 Mar 2020 18:21:57 -0700 Subject: [PATCH] modifications from testing --- include/list.h | 21 ++++++++++++++++++++- include/queue.h | 1 + include/task.h | 5 ++++- list.c | 3 +++ queue.c | 4 ++++ tasks.c | 14 +++++++------- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/include/list.h b/include/list.h index 0598a935f..a8ba2baf4 100644 --- a/include/list.h +++ b/include/list.h @@ -167,7 +167,8 @@ typedef struct xLIST volatile UBaseType_t uxNumberOfItems; 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 (). */ 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. */ - listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + void* pvOwner; /* Pointer to the object that owns the list (normally an RTOS object) */ + listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; /* @@ -216,6 +217,24 @@ typedef struct xLIST */ #define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue ) +/* +* Access macro to set the owner of a list. The owner of a list +* is the object(usually an RTOS object) that contains the list, such as semaphores. +* +* \page listSET_LIST_OWNER listSET_LIST_OWNER +* \ingroup LinkedList +*/ +#define listSET_LIST_OWNER( pxList , pxOwner ) ( ( pxList )->pvOwner = (void * ) ( pxOwner ) ) + +/* + * Access macro to get the owner of a list. The owner of a list + * is the object(usually an RTOS object) that contains the list, such as semaphores. + * + * \page listGET_LIST_OWNER listGET_LIST_OWNER + * \ingroup LinkedList + */ +#define listGET_LIST_OWNER( pxList ) ( ( pxList )->pvOwner ) + /* * Return the list item at the head of the list. * diff --git a/include/queue.h b/include/queue.h index fb8231528..7a3158d9a 100644 --- a/include/queue.h +++ b/include/queue.h @@ -38,6 +38,7 @@ extern "C" { #endif #include "task.h" +#include "list.h" /** * Type by which queues are referenced. For example, a call to xQueueCreate() diff --git a/include/task.h b/include/task.h index 05e1e767a..a375b5a90 100644 --- a/include/task.h +++ b/include/task.h @@ -162,7 +162,7 @@ typedef struct XTASK_BLOCKED_STATUS eBlockedStatus eStatus; union { - List_t *pxEventList; + List_t const *pxEventList; TickType_t xUntilTick; }; } TaskBlockedStatus_t; @@ -1812,6 +1812,9 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; * and the task is waiting for a notification. If the task is blocked but neither eBlockedForEvent nor eBlockedForNotification, * eStatus will be eBlockedForTime and xUntilTick will be assigned the tick value at which the task can exit the blocked state. * list. If the task is not blocked, eStatus will be eNotBlocked. + * + * Some RTOS objects establish ownership of their event lists, such as semaphores. To retrieve the owner of the event list, + * you can call listGET_LIST_OWNER() to get a void * pointer to the * * @param xTask The handle of the task to query. If xTask == NULL, the current running task is evaluated. * diff --git a/list.c b/list.c index 0e0e72d82..530bcea91 100644 --- a/list.c +++ b/list.c @@ -36,6 +36,9 @@ void vListInitialise( List_t * const pxList ) { + /* Ownership of a list is claimed/queried via listLIST_SET_OWNER and listLIST_GET_OWNER*/ + pxList->pvOwner = NULL; + /* The list structure contains a list item which is used to mark the end of the list. To initialise the list the list end is inserted as the only list entry. */ diff --git a/queue.c b/queue.c index 14ad01ec9..05d6ce397 100644 --- a/queue.c +++ b/queue.c @@ -445,6 +445,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseT pxNewQueue->uxItemSize = uxItemSize; ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); + /* Establish two-way link with event lists */ + listSET_LIST_OWNER(&pxNewQueue->xTasksWaitingToReceive, pxNewQueue); + listSET_LIST_OWNER(&pxNewQueue->xTasksWaitingToSend, pxNewQueue); + #if ( configUSE_TRACE_FACILITY == 1 ) { pxNewQueue->ucQueueType = ucQueueType; diff --git a/tasks.c b/tasks.c index f5bbeac5d..46e0f3575 100644 --- a/tasks.c +++ b/tasks.c @@ -5177,10 +5177,10 @@ TickType_t uxReturn; #endif /*-----------------------------------------------------------*/ -#if ( INCLUDE_eTaskGetBlocker == 1 ) +#if ( INCLUDE_vTaskGetCurrentBlocker == 1 ) void vTaskGetCurrentBlocker(TaskHandle_t xTask, TaskBlockedStatus_t* pxBlockedStatus) { - List_t const *pxStateList, * pxEventList, * pxDelayedList, * pxOverflowDelayedList + List_t const* pxStateList, * pxEventList, * pxDelayedList, * pxOverflowDelayedList; const TCB_t * const pxTCB = xTask; TickType_t xStateListItemValue = 0u; #if (configUSE_TASK_NOTIFICATIONS == 1) @@ -5188,7 +5188,7 @@ TickType_t uxReturn; #endif memset(pxBlockedStatus, 0u, sizeof(TaskBlockedStatus_t)); - pxBlockedStatus = eNotBlocked; + pxBlockedStatus->eStatus = eNotBlocked; /* Per convention NULL operates for current task. Current task can't be blocked if its running this function */ @@ -5201,7 +5201,7 @@ TickType_t uxReturn; pxEventList = listLIST_ITEM_CONTAINER(&(pxTCB->xEventListItem)); pxDelayedList = pxDelayedTaskList; pxOverflowDelayedList = pxOverflowDelayedTaskList; - xStateListItemValue = pxTCB->xStateListItem->xItemValue; + xStateListItemValue = pxTCB->xStateListItem.xItemValue; #if (configUSE_TASK_NOTIFICATIONS == 1) { ucNotifyState = pxTCB->ucNotifyState; @@ -5240,15 +5240,15 @@ TickType_t uxReturn; block indefinitely and is instead placed on the xSuspendTaskList. */ if (pxEventList != NULL) { - eBlockedStatus->eStatus = eBlockedForEvent; - eBlockedStatus->eEventList = pxEventList; + pxBlockedStatus->eStatus = eBlockedForEvent; + pxBlockedStatus->pxEventList = pxEventList; } else { #if (configUSE_TASK_NOTIFICATIONS) if (ucNotifyState == taskWAITING_NOTIFICATION) { - eBlockedStatus = eBlockedForNotification; + pxBlockedStatus->eStatus = eBlockedForNotification; } else {