Split traceTASK_NOTIFY_TAKE into _EXT and _FAILED hooks.

The old traceTASK_NOTIFY_TAKE hook was always called (no matter the
success or failure of the action) and did not hygienically expose
enough information for the tracer to determine the state of the task
notification after it has been taken.

The new traceTASK_NOTIFY_TAKE_EXT hook is called only if
the notification was taken successfully and hygienically expose
xClearCountOnExit.

The new traceTASK_NOTIFY_TAKE_FAILED hook is called if the notification
could not be taken.

This matches how the tracing hooks for all other APIs that attempt to
receive/take a resource and my block function: First, if the task blocks,
a BLOCK or BLOCKING trace hook is called. Then, either a normal or
FAILED trace hook is called, indicating if the operation timed out or
succeeded.

Both hooks fall back on the old traceTASK_NOTIFY_TAKE, preserving its
functionality for backwards compatibility.
This commit is contained in:
schilkp 2024-06-06 08:45:29 +02:00
parent 93f008b8bb
commit 402f715cb2
2 changed files with 20 additions and 1 deletions

View file

@ -992,6 +992,23 @@
#define traceTASK_NOTIFY_TAKE( uxIndexToWait )
#endif
#ifndef traceTASK_NOTIFY_TAKE_EXT
/* Extended version of traceTASK_NOTIFY_TAKE that also exposes value of
* xClearCountOnExit, informing the tracer of the state of this task
* notification after it has been taken. Note that this hook, unlike traceTASK_NOTIFY_TAKE,
* is only called if the notification was successfully taken. */
#define traceTASK_NOTIFY_TAKE_EXT( uxIndexToWait, xClearCountOnExit ) traceTASK_NOTIFY_TAKE( uxIndexToWait )
#endif
#ifndef traceTASK_NOTIFY_TAKE_FAILED
/* Task notification take failed. For backwards-compatability, this macro falls
* back on traceTASK_NOTIFY_TAKE which was always called, no matter if
* successfull or not. */
#define traceTASK_NOTIFY_TAKE_FAILED( uxIndexToWait ) traceTASK_NOTIFY_TAKE( uxIndexToWait )
#endif
#ifndef traceTASK_NOTIFY_WAIT_BLOCK
#define traceTASK_NOTIFY_WAIT_BLOCK( uxIndexToWait )
#endif

View file

@ -7682,11 +7682,12 @@ TickType_t uxTaskResetEventItemValue( void )
taskENTER_CRITICAL();
{
traceTASK_NOTIFY_TAKE( uxIndexToWaitOn );
ulReturn = pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ];
if( ulReturn != 0U )
{
traceTASK_NOTIFY_TAKE_EXT( uxIndexToWaitOn, xClearCountOnExit );
if( xClearCountOnExit != pdFALSE )
{
pxCurrentTCB->ulNotifiedValue[ uxIndexToWaitOn ] = ( uint32_t ) 0U;
@ -7698,6 +7699,7 @@ TickType_t uxTaskResetEventItemValue( void )
}
else
{
traceTASK_NOTIFY_TAKE_FAILED( uxIndexToWaitOn );
mtCOVERAGE_TEST_MARKER();
}