Quality RTOS & Embedded Software

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




Loading

best way to "switch" tasks

Posted by matejm on November 6, 2013

Hi, i have some problems how to "control" tasks... i have one main task which control others "reporting" tasks, which read data from sensors, sending data to server etc... but they'll run occasionally some of them will run once per day others few times on month

now i'm wondering how should i do that and why is one way better than other?

a) suspending/resuming tasks b) changing their priorities

i didn't find any specific info at http://www.freertos.org/a00112.html when should i use one of them... if i choose b) and raise priority to one task, scheduler won't run other task until i don't set low priority to it... what is diffrent if i choose way a) - i run task with highest priority and when is finished i suspend it...

best regards, Matej


best way to "switch" tasks

Posted by davedoors on November 6, 2013

If you need tasks to do these periodic actions then my answer assumes the functionality is unsuitable to be done in a software timer.

The other tasks must be tightly synchronized with the controlling task then you could have the other tasks suspend themselves when they have finished their action. The controlling task can then unsuspend them when it is time for them to perform their action again.


best way to "switch" tasks

Posted by matejm on November 6, 2013

Dave, thanks for reply, tasks - actions are not peridoic... i think that suspending tasks is best choose because task is in suspended state and scheduler doesn't have to mess with it (until i resume it )... if i changing a priority - task is in a Ready mode and scheduler will looking between more tasks (for each task at least one or more comparation)


best way to "switch" tasks

Posted by richard_damon on November 7, 2013

Generally i have tasks switch by having them wait on something (like a semaphore or queue) which tells them they have something to do. Trying to starts/stop tasks with resumes or priorities generally indicates that not enough effort has gone into figuring out when they are supposed to run and what they are supposed to do.

Tasks in the Blocked state don't take attention of the scheduler.


[ 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