Skip to content

Commit b9a1747

Browse files
committed
Adjustments to tasks from PR review
1 parent ad317ef commit b9a1747

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

tasks.c

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t
410410

411411
/* File private functions. --------------------------------*/
412412

413+
/*
414+
* Creates the idle tasks during scheduler start
415+
*/
416+
static BaseType_t prvCreateIdleTasks( void );
417+
413418
/*
414419
* Returns the yield pending count for the calling core.
415420
*/
@@ -460,11 +465,6 @@ static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION;
460465
* The idle task is automatically created and added to the ready lists upon
461466
* creation of the first user task.
462467
*
463-
* The portTASK_FUNCTION_PROTO() macro is used to allow port/compiler specific
464-
* language extensions. The equivalent prototype for this function is:
465-
*
466-
* void prvIdleTask( void *pvParameters );
467-
*
468468
*/
469469
static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION;
470470
#if ( configNUM_CORES > 1 )
@@ -1548,11 +1548,20 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
15481548
pxNewTCB->xTaskRunState = taskTASK_NOT_RUNNING;
15491549

15501550
/* Is this an idle task? */
1551+
if(pxTaskCode == prvIdleTask)
1552+
{
1553+
pxNewTCB->xIsIdle = pdTRUE;
1554+
}
15511555
#if(configNUM_CORES > 1)
1552-
pxNewTCB->xIsIdle = ( pxTaskCode == prvIdleTask ) || (pxTaskCode == prvMinimalIdleTask);
1553-
#else
1554-
pxNewTCB->xIsIdle = ( pxTaskCode == prvIdleTask );
1556+
else if(pxTaskCode == prvMinimalIdleTask)
1557+
{
1558+
pxNewTCB->xIsIdle = pdTRUE;
1559+
}
15551560
#endif
1561+
else
1562+
{
1563+
pxNewTCB->xIsIdle = pdFALSE;
1564+
}
15561565

15571566
if( pxCreatedTask != NULL )
15581567
{
@@ -2605,19 +2614,13 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
26052614
#endif /* ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) */
26062615
/*-----------------------------------------------------------*/
26072616

2608-
void vTaskStartScheduler( void )
2617+
static BaseType_t prvCreateIdleTasks( void )
26092618
{
2610-
BaseType_t xReturn;
2619+
BaseType_t xReturn = pdPASS;
26112620
BaseType_t xCoreID;
26122621
char cIdleName[ configMAX_TASK_NAME_LEN ];
26132622

2614-
#if ( configUSE_TIMERS == 1 )
2615-
{
2616-
xReturn = xTimerCreateTimerTask();
2617-
}
2618-
#endif /* configUSE_TIMERS */
2619-
2620-
/* Add each idle task at the lowest priority. */
2623+
/* Add each idle task at the lowest priority. */
26212624
for( xCoreID = ( BaseType_t ) 0; xCoreID < ( BaseType_t ) configNUM_CORES; xCoreID++ )
26222625
{
26232626
BaseType_t x;
@@ -2690,18 +2693,16 @@ void vTaskStartScheduler( void )
26902693
#if( configNUM_CORES > 1)
26912694
else
26922695
{
2693-
struct taskMemory{
2694-
StaticTask_t TCB;
2695-
StackType_t stack[configMINIMAL_STACK_SIZE];
2696-
};
2697-
static struct taskMemory idleMemory[configNUM_CORES];
2696+
static StaticTask_t xIdleTCBBuffers[configNUM_CORES-1];
2697+
static StackType_t xIdleTaskStackBuffers[configMINIMAL_STACK_SIZE][configNUM_CORES-1];
2698+
26982699
xIdleTaskHandle[ xCoreID ] = xTaskCreateStatic( prvMinimalIdleTask,
26992700
cIdleName,
27002701
configMINIMAL_STACK_SIZE,
27012702
( void * ) NULL, /*lint !e961. The cast is not redundant for all compilers. */
27022703
portPRIVILEGE_BIT, /* In effect ( tskIDLE_PRIORITY | portPRIVILEGE_BIT ), but tskIDLE_PRIORITY is zero. */
2703-
idleMemory[xCoreID].stack,
2704-
&idleMemory[xCoreID].TCB ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
2704+
xIdleTaskStackBuffers[xCoreID-1],
2705+
&xIdleTCBBuffers[xCoreID-1] ); /*lint !e961 MISRA exception, justified as it is not a redundant explicit cast to all supported compilers. */
27052706
}
27062707
#endif
27072708
if( xIdleTaskHandle[ xCoreID ] != NULL )
@@ -2739,6 +2740,20 @@ void vTaskStartScheduler( void )
27392740
}
27402741
#endif /* configSUPPORT_STATIC_ALLOCATION */
27412742
}
2743+
return xReturn;
2744+
}
2745+
2746+
void vTaskStartScheduler( void )
2747+
{
2748+
BaseType_t xReturn;
2749+
2750+
#if ( configUSE_TIMERS == 1 )
2751+
{
2752+
xReturn = xTimerCreateTimerTask();
2753+
}
2754+
#endif /* configUSE_TIMERS */
2755+
2756+
xReturn = prvCreateIdleTasks();
27422757

27432758
if( xReturn == pdPASS )
27442759
{
@@ -4190,11 +4205,6 @@ void vTaskMissedYield( void )
41904205
* The MinimalIdle task.
41914206
* ----------------------------------------------------------
41924207
*
4193-
* The portTASK_FUNCTION() macro is used to allow port/compiler specific
4194-
* language extensions. The equivalent prototype for this function is:
4195-
*
4196-
* void prvMinimalIdleTask( void *pvParameters );
4197-
*
41984208
* The minimal idle task is used for all the additional Cores in a SMP system.
41994209
* There must be only 1 idle task and the rest are minimal idle tasks.
42004210
*
@@ -4245,10 +4255,6 @@ static portTASK_FUNCTION( prvMinimalIdleTask, pvParameters )
42454255
* The Idle task.
42464256
* ----------------------------------------------------------
42474257
*
4248-
* The portTASK_FUNCTION() macro is used to allow port/compiler specific
4249-
* language extensions. The equivalent prototype for this function is:
4250-
*
4251-
* void prvIdleTask( void *pvParameters );
42524258
*
42534259
*/
42544260
static portTASK_FUNCTION( prvIdleTask, pvParameters )

0 commit comments

Comments
 (0)