Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Is it valid to call vTaskResume() from ISR?

Posted by Alexander Horoshilov on May 16, 2006

I need to stop task execution until event occurs. I detect this event in ISR. May I use vTaskSuspend(0) to suspend task and resume it later with vTaskResume() call from ISR. I've tried both cooperative and preemption modes, in both cases I've got similar results - the task does not work properly after resuming (in some cases stack is corrupted, other unexpected behaviour is also detected).

Before I dig in my code with bug search, I'd like to know is it legal to call vTaskResume from ISR. From what I saw in sources, it should be, but I didn't found explicit statement which confirms this.


RE: Is it valid to call vTaskResume() from ISR?

Posted by Nobody/Anonymous on May 16, 2006
From a quick look at the source I would suggest:

TaskSuspend cannot be used from an ISR.

TaskResume can be used from an ISR provided the task being resumed has a priority less than the task that was interrupted.

The problem if the task being resumed has a priority higher than or equal to the current (interrupted) task is that a yield will be called. This cannot be done from an ISR. Each port provides a way of calling a yield at the end of the ISR function (portEND_SWITCHING_ISR macro in my case).

If you want to resume a task from an ISR then either block the task using a queue and unblock it using a queuesendfromisr() call but this is not efficient, or modify the code so that the vTaskResume() function does not call yield. If you want you can get vTaskResume to return a bool to say if a yield is required or not. This is the difference between queue send and queue send from isr.

RE: Is it valid to call vTaskResume() from ISR?

Posted by Alexander Horoshilov on May 16, 2006
It seems to be exactly my case -- suspended task is of higher priority. Thank you for the clarification, I'll redesign my app.

RE: Is it valid to call vTaskResume() from IS

Posted by Jeff Smith on May 18, 2006
I think what you want is a queue (or semaphore).

xQueueSendFromISR() or xSemaphoreGiveFromISR() is what the ISR would call to wake the task.

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists