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




Loading

calling vTaskDelete when in critical section

Posted by mizer on April 2, 2009
Hi,

In case it matters I'm using the AVR32 UC3A port.

While in one task I'm calling vTaskDelete to delete a different task. It happens my code to make the vTaskDelete call is within a short taskENTER_CRITICAL section. I see at the end of the vTaskDelete function a taskYield request. My code would still have this within a taskCRITICAL section (due to the nested taskCRITICAL calls). Is this okay?

As I think about this further ... it seems the act of the taskYIELD call (at the end of the vTaskDelete function) could actually cause a context switch and therefore defeat the purpose of my CRITICAL section. But since we are in a CRITICAL section [by my doing] no event (an interrupt) could've taken place that would set up an an actual task yield. I think the task yield section at the end of the vTaskDelete function is primarily for when a task deletes itself (because I suspect you never return from the vTaskDelete function in that case).

So the first paragraph is my real question.

Any comments appreciated.

I sure am enjoying freeRTOS. Seriously!

Thanks,
Bob.

RE: calling vTaskDelete when in critical sect

Posted by Richard on April 3, 2009
The Yield at the end of vTaskDelete() is to ensure you yield away from the task that has now been deleted, as it (conceptually) no longer exists (assuming you are deleting the running task rather another task).

Some ports will yield immediately and some will hold it pending until you exit the critical section - I cannot remember off hand which the AVR32 port does. If it yields immediately then any code you place between deleting the task and exiting your critical section will never run because the task will have yielded to another task and never run again (again this assumes you are deleting the running task rather than another task).

Regards.


[ 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