Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


vTaskSuspend and xTaskResumeAll

Posted by Karsten Klein on November 14, 2008
I have a question concerning taskSuspend and resuming it.

There is one Task (TASK_A) which will be suspended by using:
vTaskSuspend( NULL ).

The resume of TASK_A will be done in an ISR after a DMA transfer_complete_interrupt by:


In an other Task (TASK_B) it might happen in the meanwhile (where the TASK_A is suspended) , that a vTaskSuspendAll() and a xTaskResumeAll() is executed.

Does the xTaskResumeAll() from TASK_B automatically resume the TASK_A as well, or is there a difference between the both mechanisms.

Thank you very much in advance


RE: vTaskSuspend and xTaskResumeAll

Posted by Richard on November 14, 2008
A couple of points:

1) Be careful with the usage scenario of using xTaskResumeFromISR(). If you are wanting to wake a task when an event occurs it is normally more appropriate to use a semaphore, otherwise events can be missed.

2) xTaskResumeAll() does not effect tasks that are in the suspeneded state. Probably not a good name for the function (in fact in SafeRTOS the name was changed to xTaskResumeScheduler()). SuspendAll() suspends the scheduler so no reschedules occur. ResumeAll() resumes the scheduler so priority based scheduling happens as per normal. The state of individual tasks is not effected.


RE: vTaskSuspend and xTaskResumeAll

Posted by Karsten Klein on November 14, 2008
Hi Richard,
thank you very much. Item 2 is understood.

But how can events be missed by using xTaskResumeFromISR() ?

The DMA-Transfer_Complete interrupt (by the way it´s an AVR32) occured and xTaskResumeFromISR(xHandleBusTask) is executed.
So the TASK_A should be resumed, and scheduled again, as soon as possible.

Or are there other items I didn´t concider ?

Best regards

RE: vTaskSuspend and xTaskResumeAll

Posted by Richard on November 14, 2008
Consider the case where a task is structured thus:

void vATask( void * pvParameters )
________/* Wait for an event. */
________vTaskSuspend( NULL );

________/* If the task is running now then the interrupt must have
________resumed it. */

________/* A */

________/* Process the event. */

________/* B */

so this is a simple task that executes each time it is resumed, processes an event that resumed it, then suspends itself again to wait for the next event.

The problem is, if the event occurs again anywhere between A and B it will have occurred before the task had suspended itself - the interrupt will try to resume the task but it was not actually suspended. The task will then suspend itself when it goes back to the top of the loop, not knowing there is already data to process.

If you use a binary or counting semaphore this problem goes away. Instead of suspending itself the task blocks on the semaphore. In the ISR the code simply gives the semaphore to unblock the task.


RE: vTaskSuspend and xTaskResumeAll

Posted by Karsten Klein on November 14, 2008
understood so far. This can happen. A semaphore is the better choise for that.

In my situation there is always a gap of at least 3ms between the TaskSuspend and the event (ISR) which resumes the task. The event is allways a direct followup of the start of the DMA-transfer which happen straight before the taskSuspend.

Anyway I understand the point and will investigate in going with a semaphore. This seems to be more safety.

Thank you very much.

Best Regards

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner