@ -153,17 +153,28 @@ Changes from V4.0.0
Changes from V4 .0 .1
+ The function vTaskList ( ) now suspends the scheduler rather than disabling
interrup s during the creation of the task list .
interrup t s during the creation of the task list .
+ Allow a task to delete itself by passing in its own handle . Previously
this could only be done by passing in NULL .
+ The tick hook function is now called only within a tick isr . Previously
it was also called when the tick function was called during the scheduler
unlocking process .
Changes from V4 .0 . 4
Changes from V4 .0 . 3
+ Extra checks have been placed in vTaskPrioritySet ( ) to avoid unnecessary
yields .
Changed from V4 .0 .4
+ Bug fix : The ' value ' of the event list item is updated when the priority
of a task is changed . Previously only the priority of the TCB itself was
changed .
+ When resuming a task a check is first made to see if the task is actually
suspended .
+ vTaskPrioritySet ( ) and vTaskResume ( ) no longer use the event list item .
This has not been necessary since V4 .0 .1 when the xMissedYield handling
was added .
*/
# include <stdio.h>
@ -337,7 +348,6 @@ static volatile portBASE_TYPE xMissedYield = ( portBASE_TYPE ) pdFALSE;
vListInsertEnd ( ( xList * ) & ( pxReadyTasksLists [ pxTCB - > uxPriority ] ) , & ( pxTCB - > xGenericListItem ) ) ; \
}
/*
* Macro that looks at the list of tasks that are currently delayed to see if
* any require waking .
@ -615,11 +625,14 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
taskEXIT_CRITICAL ( ) ;
/* Force a reschedule if we have just deleted the current task. */
if ( xSchedulerRunning ! = pdFALSE )
{
if ( ( void * ) pxTaskToDelete = = NULL )
{
taskYIELD ( ) ;
}
}
}
# endif
@ -831,27 +844,20 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
}
pxTCB - > uxPriority = uxNewPriority ;
listSET_LIST_ITEM_VALUE ( & ( pxTCB - > xEventListItem ) , configMAX_PRIORITIES - ( portTickType ) uxNewPriority ) ;
/* If the task is in the blocked or suspended list we need do
nothing more than change it ' s priority variable . However , if
the task is in a ready list it needs to be removed and placed
in the queue appropriate to its new priority . */
if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ uxCurrentPriority ] ) , & ( pxTCB - > xGenericListItem ) ) )
{
if ( uxSchedulerSuspended = = ( unsigned portBASE_TYPE ) pdFALSE )
{
/* The task is currently in its ready list - remove before adding
it to it ' s new ready list . */
it to it ' s new ready list . As we are in a critical section we
can do this even if the scheduler is suspended . */
vListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyQueue ( pxTCB ) ;
}
else
{
/* We cannot access the delayed or ready lists, so will hold this
task pending until the scheduler is resumed . */
vListInsertEnd ( ( xList * ) & ( xPendingReadyList ) , & ( pxTCB - > xEventListItem ) ) ;
}
}
if ( xYieldRequired = = pdTRUE )
{
@ -911,7 +917,6 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
void vTaskResume ( xTaskHandle pxTaskToResume )
{
tskTCB * pxTCB ;
portBASE_TYPE xYieldRequired ;
/* Remove the task from whichever list it is currently in, and place
it in the ready list . */
@ -923,24 +928,16 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
{
taskENTER_CRITICAL ( ) ;
{
if ( uxSchedulerSuspended = = ( unsigned portBASE_TYPE ) pdFALSE )
/* Is the task we are attempting to resume actually suspended? */
if ( listIS_CONTAINED_WITHIN ( & xSuspendedTaskList , & ( pxTCB - > xGenericListItem ) ) ! = pdFALSE )
{
xYieldRequired = ( pxTCB - > uxPriority > = pxCurrentTCB - > uxPriority ) ;
/* As we are in a critical section we can access the ready
lists even if the scheduler is suspended . */
vListRemove ( & ( pxTCB - > xGenericListItem ) ) ;
prvAddTaskToReadyQueue ( pxTCB ) ;
}
else
{
/* We cannot access the delayed or ready lists, so will hold this
task pending until the scheduler is resumed . */
xYieldRequired = pdFALSE ;
vListInsertEnd ( ( xList * ) & ( xPendingReadyList ) , & ( pxTCB - > xEventListItem ) ) ;
}
}
taskEXIT_CRITICAL ( ) ;
/* We may have just resumed a higher priority task. */
if ( xYieldRequired )
if ( pxTCB - > uxPriority > = pxCurrentTCB - > uxPriority )
{
/* This yield may not cause the task just resumed to run, but
will leave the lists in the correct state for the next yield . */
@ -948,9 +945,42 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
}
}
}
taskEXIT_CRITICAL ( ) ;
}
}
# endif
/*-----------------------------------------------------------*/
# if ( INCLUDE_vTaskResumeFromISR == 1 )
portBASE_TYPE xTaskResumeFromISR ( xTaskHandle pxTaskToResume )
{
portBASE_TYPE xYieldRequired ;
/* Is the task we are attempting to resume actually suspended? */
if ( listIS_CONTAINED_WITHIN ( & xSuspendedTaskList , & ( pxTaskToResume - > xGenericListItem ) ) ! = pdFALSE )
{
if ( uxSchedulerSuspended = = ( unsigned portBASE_TYPE ) pdFALSE )
{
xYieldRequired = ( pxTaskToResume - > uxPriority > = pxCurrentTCB - > uxPriority ) ;
vListRemove ( & ( pxTaskToResume - > xGenericListItem ) ) ;
prvAddTaskToReadyQueue ( pxTaskToResume ) ;
}
else
{
/* We cannot access the delayed or ready lists, so will hold this
task pending until the scheduler is resumed . */
xYieldRequired = pdFALSE ;
vListInsertEnd ( ( xList * ) & ( xPendingReadyList ) , & ( pxTaskToResume - > xEventListItem ) ) ;
}
}
return xYieldRequired ;
}
# endif