Quality RTOS & Embedded Software

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


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