Quality RTOS & Embedded Software

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




Loading

Code inside vs. outside tasks

Posted by on November 4, 2011
Hi!

I have a general question regarding tasks. Let's say that I have non-RTOS code that I would like to convert to a FreeRTOS task. The existing code performs some initialization (e.g. HW setup) only at startup and then enters the main program loop. Now if I move the code to FreeRTOS I could put all the code as is including those initialization stiff inside a task function or I could try to isolate the init stuff into my main() so that it runs before the scheduler is started. Only the main program loop would then go into the task function. Are there any benefits (e.g. resource saving) that are worth that additional program modification? Thank you in advance for the clarification.

Regards,
Anguel

RE: Code inside vs. outside tasks

Posted by Dave on November 4, 2011
Normally hardware would be set up before the scheduler was started. You can disable interrupts if necessary, as they will be automatically be re-enabled when the first task starts.

RE: Code inside vs. outside tasks

Posted by on November 4, 2011
Thank you very much for the help.

RE: Code inside vs. outside tasks

Posted by Richard Damon on November 4, 2011
My general rule is hardware initilzation (which tends to want to be done before interrupts are put "on the air") and the creating of communication resources (queue, semaphores, and mutes) generally want to be done before the scheduler starts. Sometimes a device needs a longer "configuration" protocol that might go into the beginning of a task, especially if it needs delays or interrupt responses.


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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