Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Updated Jul 2025

xTaskResumeFromISR()

[Task Control]

task. h

1BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume );

INCLUDE_vTaskSuspend
and
INCLUDE_xTaskResumeFromISR
must be defined as 1 for this function to be available. See the RTOS Configuration documentation for more information.

A function to resume a suspended task 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()
.

xTaskResumeFromISR()
is generally considered a dangerous function because its actions are not latched. For this reason it should definitely not be used to synchronise a task with an interrupt if there is a chance that the interrupt could arrive prior to the task being suspended, and therefore the interrupt being lost. Use of a semaphore, or preferable a direct to task notification, would avoid this eventuality. A worked example that uses a direct to task notification is provided.

Parameters:

  • xTaskToResume

    Handle to the task being readied.

Returns:

  • pdTRUE if resuming the task should result in a context switch,
  • pdFALSE otherwise. This is used by the ISR to determine if a context switch may be required following the ISR.

Example usage:

1TaskHandle_t xHandle;
2
3void vAFunction( void )
4{
5 // Create a task, storing the handle.
6 xTaskCreate( vTaskCode, "NAME", STACK_SIZE, NULL, tskIDLE_PRIORITY, &xHandle );
7
8 // ... Rest of code.
9}
10
11void vTaskCode( void *pvParameters )
12{
13 // The task being suspended and resumed.
14 for( ;; )
15 {
16 // ... Perform some function here.
17
18 // The task suspends itself.
19 vTaskSuspend( NULL );
20
21 // The task is now suspended, so will not reach here until the ISR resumes it.
22 }
23}
24
25void vAnExampleISR( void )
26{
27 BaseType_t xYieldRequired;
28
29 // Resume the suspended task.
30 xYieldRequired = xTaskResumeFromISR( xHandle );
31
32 // We should switch context so the ISR returns to a different task.
33 // NOTE: How this is done depends on the port you are using. Check
34 // the documentation and examples for your port.
35 portYIELD_FROM_ISR( xYieldRequired );
36}