Add trace macros into the event groups implementation.

Add a task pre-delete hook to allow the insertion of any port specific clean up when a task is deleted.
Increase use of 'const' qualifiers.
Add vPortCloseRunningThread() into the Win32 port layer to attempt to allow Windows threads to be closed more gracefully when a task deletes itself.
This commit is contained in:
Richard Barry 2013-12-12 10:19:07 +00:00
parent 0416289066
commit 6b3393b4b6
6 changed files with 129 additions and 16 deletions

View file

@ -128,6 +128,11 @@ xEVENT_BITS *pxEventBits;
{
pxEventBits->uxEventBits = 0;
vListInitialise( &( pxEventBits->xTasksWaitingForBits ) );
traceEVENT_GROUP_CREATE( pxEventBits );
}
else
{
traceEVENT_GROUP_CREATE_FAILED();
}
return ( xEventGroupHandle ) pxEventBits;
@ -148,6 +153,8 @@ portBASE_TYPE xYieldedAlready;
vTaskSuspendAll();
{
traceEVENT_GROUP_SYNC_START( xEventGroup, uxBitsToSet );
uxOriginalBitValue = pxEventBits->uxEventBits;
( void ) xEventGroupSetBits( xEventGroup, uxBitsToSet );
@ -172,6 +179,11 @@ portBASE_TYPE xYieldedAlready;
task's event list item so the kernel knows when a match is
found. Then enter the blocked state. */
vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | taskCLEAR_EVENTS_ON_EXIT_BIT | taskWAIT_FOR_ALL_BITS ), xTicksToWait );
/* This is obsolete as it will get set after the task unblocks,
but some compilers mistakenly generate a warning about the
variable being returned without being set if it is not done. */
uxReturn = 0;
}
else
{
@ -209,6 +221,7 @@ portBASE_TYPE xYieldedAlready;
}
}
traceEVENT_GROUP_SYNC_END( xEventGroup, uxReturn );
return uxReturn;
}
/*-----------------------------------------------------------*/
@ -232,6 +245,8 @@ xEventBitsType uxReturn, uxControlBits = 0;
{
const xEventBitsType uxCurrentEventBits = pxEventBits->uxEventBits;
traceEVENT_GROUP_WAIT_BITS_START( xEventGroup, uxBitsToWaitFor );
if( xWaitForAllBits == pdFALSE )
{
/* Task only has to wait for one bit within uxBitsToWaitFor to be set. Is
@ -288,6 +303,11 @@ xEventBitsType uxReturn, uxControlBits = 0;
found. Then enter the blocked state. */
vTaskPlaceOnUnorderedEventList( &( pxEventBits->xTasksWaitingForBits ), ( uxBitsToWaitFor | uxControlBits ), xTicksToWait );
portYIELD_WITHIN_API();
/* This is obsolete as it will get set after the task unblocks, but
some compilers mistakenly generate a warning about the variable
being returned without being set if it is not done. */
uxReturn = 0;
}
}
taskEXIT_CRITICAL();
@ -313,6 +333,7 @@ xEventBitsType uxReturn, uxControlBits = 0;
}
}
traceEVENT_GROUP_WAIT_BITS_END( xEventGroup, uxReturn );
return uxReturn;
}
/*-----------------------------------------------------------*/
@ -329,6 +350,8 @@ xEventBitsType uxReturn;
uxBitsToClear = ~uxBitsToClear;
taskENTER_CRITICAL();
{
traceEVENT_GROUP_CLEAR_BITS( xEventGroup, ~uxBitsToClear );
/* The value returned is the event group value prior to the bits being
cleared. */
uxReturn = pxEventBits->uxEventBits;
@ -359,6 +382,8 @@ portBASE_TYPE xMatchFound = pdFALSE;
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
vTaskSuspendAll();
{
traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
pxListItem = listGET_HEAD_ENTRY( pxList );
/* Set the bits. */
@ -432,6 +457,8 @@ const xList *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
vTaskSuspendAll();
{
traceEVENT_GROUP_DELETE( xEventGroup );
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( unsigned portBASE_TYPE ) 0 )
{
/* Unblock the task, returning 0 as the event list is being deleted