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

Ensuring idle task runs after vTaskDelete

Posted by JC on March 13, 2008
If one wanted to restart a task by deleting it with vTaskDelete() followed by xTaskCreate(), is there a way to ensure the idle task gets run to clean up between the calls?

In this particular situation, I have a task that initializes a handful of variables at startup which control which of two devices the driver talks to. The user can flip a switch to change which device is used. The cleanest method at this particular time is to have the main control task stop and restart the driver task. I just need (I think) to make sure the idle tasks gets run to clean up the TCBs and such.

Thanks,
--jc

RE: Ensuring idle task runs after vTaskDelete

Posted by David Hawks on March 14, 2008
Here are some ways:

- Have the idle task create the driver task if it has been deleted.
- Have the idle task send a message to your main control task when it detects that the driver task has been deleted.
- Have the idle task give a semaphore every time it runs and have the main control task pend on the semaphore after deleting the driver task.

The last method is the most generic, but it does add extra overhead to the idle task.

RE: Ensuring idle task runs after vTaskDelete

Posted by JC on March 14, 2008
The last idea was the one I had already come up with, but I was hoping there was a less hackish way of doing this.

It would seem that if vTaskDelete() and xTaskCreate() are being used, there should be some way of enforcing the clean up. Yes, sooner or later the idle task will run, but guaranteeing when is more difficult.

--jc

RE: Ensuring idle task runs after vTaskDelete

Posted by David Hawks on March 14, 2008
The idle task calls the static function prvCheckTasksWaitingTermination() to finish deleting tasks. Perhaps you could make this public and call it after you call vTaskDelete(). You must be careful not to do this from the task you deleted, though. Of course, you're not sticking to the API if you do this, but it is a more elegant solution.


[ 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