mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Implement xTaskResumeFromISR.
This commit is contained in:
parent
430893f5f8
commit
58a357e6e6
|
@ -533,6 +533,26 @@ void vTaskSuspend( xTaskHandle pxTaskToSuspend );
|
|||
*/
|
||||
void vTaskResume( xTaskHandle pxTaskToResume );
|
||||
|
||||
/**
|
||||
* task. h
|
||||
* <pre>void xTaskResumeFromISR( xTaskHandle pxTaskToResume );</pre>
|
||||
*
|
||||
* INCLUDE_xTaskResumeFromISR must be defined as 1 for this function to be
|
||||
* available. See the configuration section for more information.
|
||||
*
|
||||
* An implementation of vTaskResume() that can be called from within an ISR.
|
||||
*
|
||||
* A task that has been suspended by one of more calls to vTaskSuspend ()
|
||||
* will be made available for running again by a single call to
|
||||
* xTaskResumeFromISR ().
|
||||
*
|
||||
* @param pxTaskToResume Handle to the task being readied.
|
||||
*
|
||||
* \defgroup vTaskResumeFromISR vTaskResumeFromISR
|
||||
* \ingroup TaskCtrl
|
||||
*/
|
||||
portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume );
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* SCHEDULER CONTROL
|
||||
*----------------------------------------------------------*/
|
||||
|
|
|
@ -175,6 +175,7 @@ Changed from V4.0.4
|
|||
+ 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.
|
||||
+ Implement xTaskResumeFromISR().
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -211,6 +212,9 @@ Changed from V4.0.4
|
|||
#define configMAX_TASK_NAME_LEN 1
|
||||
#endif
|
||||
|
||||
#ifndef INCLUDE_xTaskResumeFromISR
|
||||
#define INCLUDE_xTaskResumeFromISR 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Task control block. A task control block (TCB) is allocated to each task,
|
||||
|
@ -930,6 +934,9 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
|
|||
{
|
||||
/* Is the task we are attempting to resume actually suspended? */
|
||||
if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )
|
||||
{
|
||||
/* Has the task already been resumed from within an ISR? */
|
||||
if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE )
|
||||
{
|
||||
/* As we are in a critical section we can access the ready
|
||||
lists even if the scheduler is suspended. */
|
||||
|
@ -945,6 +952,7 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
}
|
||||
|
@ -953,33 +961,35 @@ static unsigned portBASE_TYPE uxTaskNumber = 0; /*lint !e956 Static is deliberat
|
|||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
#if ( INCLUDE_vTaskResumeFromISR == 1 )
|
||||
#if ( INCLUDE_xTaskResumeFromISR == 1 )
|
||||
|
||||
portBASE_TYPE xTaskResumeFromISR( xTaskHandle pxTaskToResume )
|
||||
{
|
||||
portBASE_TYPE xYieldRequired;
|
||||
portBASE_TYPE xYieldRequired = pdFALSE;
|
||||
tskTCB *pxTCB;
|
||||
|
||||
pxTCB = ( tskTCB * ) pxTaskToResume;
|
||||
|
||||
/* Is the task we are attempting to resume actually suspended? */
|
||||
if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTaskToResume->xGenericListItem ) ) != pdFALSE )
|
||||
if( listIS_CONTAINED_WITHIN( &xSuspendedTaskList, &( pxTCB->xGenericListItem ) ) != pdFALSE )
|
||||
{
|
||||
/* Has the task already been resumed from within an ISR? */
|
||||
if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxTCB->xEventListItem ) ) != pdTRUE )
|
||||
{
|
||||
if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
|
||||
{
|
||||
xYieldRequired = ( pxTaskToResume->uxPriority >= pxCurrentTCB->uxPriority );
|
||||
vListRemove( &( pxTaskToResume->xGenericListItem ) );
|
||||
prvAddTaskToReadyQueue( pxTaskToResume );
|
||||
xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );
|
||||
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, at which point a
|
||||
yield will be preformed if necessary. */
|
||||
xYieldRequired = pdFALSE;
|
||||
vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTaskToResume->xEventListItem ) );
|
||||
vListInsertEnd( ( xList * ) &( xPendingReadyList ), &( pxTCB->xEventListItem ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xYieldRequired = pdFALSE;
|
||||
}
|
||||
|
||||
return xYieldRequired;
|
||||
|
|
Loading…
Reference in a new issue