Quality RTOS & Embedded Software

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


Loading

Is it valid to call vTaskResume() from ISR?

Posted by Alexander Horoshilov on May 16, 2006
Hello,

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.

WBR,
Alexander

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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

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

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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