mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-07-05 11:57:15 -04:00
Compare commits
1 commit
aa9b84d0be
...
8b2c5519f3
Author | SHA1 | Date | |
---|---|---|---|
|
8b2c5519f3 |
|
@ -39,6 +39,8 @@
|
||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
#include <timers.h>
|
#include <timers.h>
|
||||||
#include <semphr.h>
|
#include <semphr.h>
|
||||||
|
|
||||||
|
/* Standard includes. */
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
@ -60,32 +62,6 @@ static void exampleTask( void * parameters )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Test uxTaskGetAllHandles API before starting the scheduler */
|
|
||||||
static void test_uxTaskGetAllHandles(void)
|
|
||||||
{
|
|
||||||
UBaseType_t uxCount, uxFilled, i;
|
|
||||||
TaskHandle_t *pxHandles;
|
|
||||||
|
|
||||||
/* First, query the number of tasks (should be 1: exampleTask, before scheduler starts) */
|
|
||||||
uxCount = uxTaskGetAllHandles(NULL, 0);
|
|
||||||
printf("[uxTaskGetAllHandles] Number of tasks: %lu\n", (unsigned long)uxCount);
|
|
||||||
|
|
||||||
if (uxCount > 0) {
|
|
||||||
pxHandles = (TaskHandle_t *)pvPortMalloc(sizeof(TaskHandle_t) * uxCount);
|
|
||||||
if (pxHandles != NULL) {
|
|
||||||
uxFilled = uxTaskGetAllHandles(pxHandles, uxCount);
|
|
||||||
printf("[uxTaskGetAllHandles] Handles returned: %lu\n", (unsigned long)uxFilled);
|
|
||||||
for (i = 0; i < uxFilled; i++) {
|
|
||||||
printf(" Handle[%lu]: %p\n", (unsigned long)i, (void *)pxHandles[i]);
|
|
||||||
}
|
|
||||||
vPortFree(pxHandles);
|
|
||||||
} else {
|
|
||||||
printf("[uxTaskGetAllHandles] pvPortMalloc failed!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*-----------------------------------------------------------*/
|
|
||||||
|
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
static StaticTask_t exampleTaskTCB;
|
static StaticTask_t exampleTaskTCB;
|
||||||
|
|
2430
include/task.h
2430
include/task.h
File diff suppressed because it is too large
Load diff
1
list.c
1
list.c
|
@ -216,6 +216,7 @@ void vListInsert( List_t * const pxList,
|
||||||
|
|
||||||
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
|
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove )
|
||||||
{
|
{
|
||||||
|
configASSERT( pxItemToRemove->pxContainer != NULL );
|
||||||
/* The list item knows which list it is in. Obtain the list from the list
|
/* The list item knows which list it is in. Obtain the list from the list
|
||||||
* item. */
|
* item. */
|
||||||
List_t * const pxList = pxItemToRemove->pxContainer;
|
List_t * const pxList = pxItemToRemove->pxContainer;
|
||||||
|
|
67
tasks.c
67
tasks.c
|
@ -4514,73 +4514,6 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery )
|
||||||
#endif /* configUSE_TRACE_FACILITY */
|
#endif /* configUSE_TRACE_FACILITY */
|
||||||
/*----------------------------------------------------------*/
|
/*----------------------------------------------------------*/
|
||||||
|
|
||||||
UBaseType_t uxTaskGetAllHandles(TaskHandle_t *pxTaskHandleArray, UBaseType_t uxArraySize)
|
|
||||||
{
|
|
||||||
UBaseType_t uxCount = 0, uxQueue;
|
|
||||||
TCB_t *pxTCB;
|
|
||||||
List_t *pxList;
|
|
||||||
ListItem_t *pxIterator, *pxEndMarker;
|
|
||||||
|
|
||||||
vTaskSuspendAll();
|
|
||||||
{
|
|
||||||
/* Ready lists */
|
|
||||||
for (uxQueue = 0; uxQueue < configMAX_PRIORITIES; uxQueue++) {
|
|
||||||
pxList = &pxReadyTasksLists[uxQueue];
|
|
||||||
pxEndMarker = listGET_END_MARKER(pxList);
|
|
||||||
for (pxIterator = listGET_HEAD_ENTRY(pxList);
|
|
||||||
pxIterator != pxEndMarker;
|
|
||||||
pxIterator = listGET_NEXT(pxIterator)) {
|
|
||||||
pxTCB = listGET_LIST_ITEM_OWNER(pxIterator);
|
|
||||||
if (uxCount < uxArraySize && pxTaskHandleArray)
|
|
||||||
pxTaskHandleArray[uxCount] = (TaskHandle_t)pxTCB;
|
|
||||||
uxCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Delayed lists */
|
|
||||||
List_t *delayedLists[] = { pxDelayedTaskList, pxOverflowDelayedTaskList };
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
pxList = delayedLists[i];
|
|
||||||
pxEndMarker = listGET_END_MARKER(pxList);
|
|
||||||
for (pxIterator = listGET_HEAD_ENTRY(pxList);
|
|
||||||
pxIterator != pxEndMarker;
|
|
||||||
pxIterator = listGET_NEXT(pxIterator)) {
|
|
||||||
pxTCB = listGET_LIST_ITEM_OWNER(pxIterator);
|
|
||||||
if (uxCount < uxArraySize && pxTaskHandleArray)
|
|
||||||
pxTaskHandleArray[uxCount] = (TaskHandle_t)pxTCB;
|
|
||||||
uxCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#if (INCLUDE_vTaskSuspend == 1)
|
|
||||||
/* Suspended list */
|
|
||||||
pxList = &xSuspendedTaskList;
|
|
||||||
pxEndMarker = listGET_END_MARKER(pxList);
|
|
||||||
for (pxIterator = listGET_HEAD_ENTRY(pxList);
|
|
||||||
pxIterator != pxEndMarker;
|
|
||||||
pxIterator = listGET_NEXT(pxIterator)) {
|
|
||||||
pxTCB = listGET_LIST_ITEM_OWNER(pxIterator);
|
|
||||||
if (uxCount < uxArraySize && pxTaskHandleArray)
|
|
||||||
pxTaskHandleArray[uxCount] = (TaskHandle_t)pxTCB;
|
|
||||||
uxCount++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if (INCLUDE_vTaskDelete == 1)
|
|
||||||
/* Deleted list (waiting for cleanup) */
|
|
||||||
pxList = &xTasksWaitingTermination;
|
|
||||||
pxEndMarker = listGET_END_MARKER(pxList);
|
|
||||||
for (pxIterator = listGET_HEAD_ENTRY(pxList);
|
|
||||||
pxIterator != pxEndMarker;
|
|
||||||
pxIterator = listGET_NEXT(pxIterator)) {
|
|
||||||
pxTCB = listGET_LIST_ITEM_OWNER(pxIterator);
|
|
||||||
if (uxCount < uxArraySize && pxTaskHandleArray)
|
|
||||||
pxTaskHandleArray[uxCount] = (TaskHandle_t)pxTCB;
|
|
||||||
uxCount++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
(void)xTaskResumeAll();
|
|
||||||
return uxCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
|
||||||
|
|
||||||
#if ( configNUMBER_OF_CORES == 1 )
|
#if ( configNUMBER_OF_CORES == 1 )
|
||||||
|
|
Loading…
Reference in a new issue