mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-08-19 09:38:32 -04:00
FreeRTOS source:
+ Previously, if a task was deleted, the memory allocated to the task by the RTOS was freed in the Idle task. Now if a task deletes another task the memory is freed immediately. The idle task is however still responsible for freeing the memory when a task deletes itself. + Added pcQueueGetQueueName() function to return the name of a queue from its handle, assuming the queue is registers. Demo application: + Update GenQTest to exercise the new pcQueueGetQueueName() function. + Delete workspaces from old Eclipse examples, leaving just the projects. + Rework comments in the MSVC simply blinky demo.
This commit is contained in:
parent
94dd3f871b
commit
7d6609f8db
347 changed files with 256 additions and 25411 deletions
|
@ -311,6 +311,7 @@ extern "C" {
|
|||
#if ( configQUEUE_REGISTRY_SIZE < 1 )
|
||||
#define vQueueAddToRegistry( xQueue, pcName )
|
||||
#define vQueueUnregisterQueue( xQueue )
|
||||
#define pcQueueGetQueueName( xQueue )
|
||||
#endif
|
||||
|
||||
#ifndef portPOINTER_SIZE_TYPE
|
||||
|
|
|
@ -1517,7 +1517,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION
|
|||
* stores a pointer to the string - so the string must be persistent (global or
|
||||
* preferably in ROM/Flash), not on the stack.
|
||||
*/
|
||||
#if configQUEUE_REGISTRY_SIZE > 0
|
||||
#if( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
#endif
|
||||
|
||||
|
@ -1531,10 +1531,25 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) PRIVILEGED_FUNCTION
|
|||
*
|
||||
* @param xQueue The handle of the queue being removed from the registry.
|
||||
*/
|
||||
#if configQUEUE_REGISTRY_SIZE > 0
|
||||
#if( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The registry is provided as a means for kernel aware debuggers to
|
||||
* locate queues, semaphores and mutexes. Call pcQueueGetQueueName() to look
|
||||
* up and return the name of a queue in the queue registry from the queue's
|
||||
* handle.
|
||||
*
|
||||
* @param xQueue The handle of the queue the name of which will be returned.
|
||||
* @return If the queue is in the registry then a pointer to the name of the
|
||||
* queue is returned. If the queue is not in the registry then NULL is
|
||||
* returned.
|
||||
*/
|
||||
#if( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
const char *pcQueueGetQueueName( QueueHandle_t xQueue );
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generic version of the queue creation function, which is in turn called by
|
||||
* any queue, semaphore or mutex creation function or macro.
|
||||
|
|
|
@ -2370,6 +2370,34 @@ BaseType_t xReturn;
|
|||
#endif /* configQUEUE_REGISTRY_SIZE */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
|
||||
const char *pcQueueGetQueueName( QueueHandle_t xQueue )
|
||||
{
|
||||
UBaseType_t ux;
|
||||
const char *pcReturn = NULL;
|
||||
|
||||
/* Note there is nothing here to protect against another task adding or
|
||||
removing entries from the registry while it is being searched. */
|
||||
for( ux = ( UBaseType_t ) 0U; ux < ( UBaseType_t ) configQUEUE_REGISTRY_SIZE; ux++ )
|
||||
{
|
||||
if( xQueueRegistry[ ux ].xHandle == xQueue )
|
||||
{
|
||||
pcReturn = xQueueRegistry[ ux ].pcQueueName;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
|
||||
return pcReturn;
|
||||
}
|
||||
|
||||
#endif /* configQUEUE_REGISTRY_SIZE */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( configQUEUE_REGISTRY_SIZE > 0 )
|
||||
|
||||
void vQueueUnregisterQueue( QueueHandle_t xQueue )
|
||||
|
@ -2384,6 +2412,11 @@ BaseType_t xReturn;
|
|||
{
|
||||
/* Set the name to NULL to show that this slot if free again. */
|
||||
xQueueRegistry[ ux ].pcQueueName = NULL;
|
||||
|
||||
/* Set the handle to NULL to ensure the same queue handle cannot
|
||||
appear in the registry twice if it is added, removed, then
|
||||
added again. */
|
||||
xQueueRegistry[ ux ].xHandle = ( QueueHandle_t ) 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -222,7 +222,7 @@ PRIVILEGED_DATA static List_t xPendingReadyList; /*< Tasks that have been r
|
|||
#if ( INCLUDE_vTaskDelete == 1 )
|
||||
|
||||
PRIVILEGED_DATA static List_t xTasksWaitingTermination; /*< Tasks that have been deleted - but their memory not yet freed. */
|
||||
PRIVILEGED_DATA static volatile UBaseType_t uxTasksDeleted = ( UBaseType_t ) 0U;
|
||||
PRIVILEGED_DATA static volatile UBaseType_t uxDeletedTasksWaitingCleanUp = ( UBaseType_t ) 0U;
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -752,10 +752,7 @@ StackType_t *pxTopOfStack;
|
|||
being deleted. */
|
||||
pxTCB = prvGetTCBFromHandle( xTaskToDelete );
|
||||
|
||||
/* Remove task from the ready list and place in the termination list.
|
||||
This will stop the task from be scheduled. The idle task will check
|
||||
the termination list and free up any memory allocated by the
|
||||
scheduler for the TCB and stack. */
|
||||
/* Remove task from the ready list. */
|
||||
if( uxListRemove( &( pxTCB->xGenericListItem ) ) == ( UBaseType_t ) 0 )
|
||||
{
|
||||
taskRESET_READY_PRIORITY( pxTCB->uxPriority );
|
||||
|
@ -775,15 +772,28 @@ StackType_t *pxTopOfStack;
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) );
|
||||
if( pxTCB == pxCurrentTCB )
|
||||
{
|
||||
/* A task is deleting itself. This cannot complete within the
|
||||
task itself, as a context switch to another task is required.
|
||||
Place the task in the termination list. The idle task will
|
||||
check the termination list and free up any memory allocated by
|
||||
the scheduler for the TCB and stack of the deleted task. */
|
||||
vListInsertEnd( &xTasksWaitingTermination, &( pxTCB->xGenericListItem ) );
|
||||
|
||||
/* Increment the ucTasksDeleted variable so the idle task knows
|
||||
there is a task that has been deleted and that it should therefore
|
||||
check the xTasksWaitingTermination list. */
|
||||
++uxTasksDeleted;
|
||||
/* Increment the ucTasksDeleted variable so the idle task knows
|
||||
there is a task that has been deleted and that it should therefore
|
||||
check the xTasksWaitingTermination list. */
|
||||
++uxDeletedTasksWaitingCleanUp;
|
||||
}
|
||||
else
|
||||
{
|
||||
--uxCurrentNumberOfTasks;
|
||||
prvDeleteTCB( pxTCB );
|
||||
}
|
||||
|
||||
/* Increment the uxTaskNumberVariable also so kernel aware debuggers
|
||||
can detect that the task lists need re-generating. */
|
||||
/* Increment the uxTaskNumber also so kernel aware debuggers can
|
||||
detect that the task lists need re-generating. */
|
||||
uxTaskNumber++;
|
||||
|
||||
traceTASK_DELETE( pxTCB );
|
||||
|
@ -1032,10 +1042,11 @@ StackType_t *pxTopOfStack;
|
|||
#endif
|
||||
|
||||
#if ( INCLUDE_vTaskDelete == 1 )
|
||||
else if( pxStateList == &xTasksWaitingTermination )
|
||||
else if( ( pxStateList == &xTasksWaitingTermination ) || ( pxStateList == NULL ) )
|
||||
{
|
||||
/* The task being queried is referenced from the deleted
|
||||
tasks list. */
|
||||
tasks list, or it is not referenced from any lists at
|
||||
all. */
|
||||
eReturn = eDeleted;
|
||||
}
|
||||
#endif
|
||||
|
@ -3071,7 +3082,7 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
|
||||
/* ucTasksDeleted is used to prevent vTaskSuspendAll() being called
|
||||
too often in the idle task. */
|
||||
while( uxTasksDeleted > ( UBaseType_t ) 0U )
|
||||
while( uxDeletedTasksWaitingCleanUp > ( UBaseType_t ) 0U )
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
{
|
||||
|
@ -3088,7 +3099,7 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
pxTCB = ( TCB_t * ) listGET_OWNER_OF_HEAD_ENTRY( ( &xTasksWaitingTermination ) );
|
||||
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
|
||||
--uxCurrentNumberOfTasks;
|
||||
--uxTasksDeleted;
|
||||
--uxDeletedTasksWaitingCleanUp;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
|
@ -3100,7 +3111,7 @@ static void prvCheckTasksWaitingTermination( void )
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif /* vTaskDelete */
|
||||
#endif /* INCLUDE_vTaskDelete */
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue