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

Task or software timer?

Posted by Paul Coleman on February 27, 2012
I have a background task which is doing a bit of housekeeping and is run every 500ms. It has the lowest priority in the system and I created it in preference to using the idel task as I want to use that for something else. However, it seems a bit of a waste of resources as it needs a stackof its own, so I thought about replacing the task with a software timer but when I looked into it that too seems to need a stack? So I'm not exactly sure what I stand to gain and I'm a little confused as to why it needs a stack, after all it's just running a callback when the timer expires???
Thanks, Paul.

RE: Task or software timer?

Posted by Richard on February 27, 2012
Software timers themselves don't need any more stack than a standard C function. However, software timer callbacks run in the context of the timer task. The timer task does need a stack (just like any other task), but there is only one timer task. Therefore, if you have 1 software timer or 10 software, the amount of additional stack required is the same.

Regards.

RE: Task or software timer?

Posted by Paul Coleman on February 27, 2012
Okay, thanks for the clarification.

I noticed that even if you create a stack size of 1 the OS will set a minimum stack size of 256 and that 256 means the number of 4 byte words not bytes. So in effect the minimum stack size is 1Kb - is my understanding correct?

Thanks, Paul.

RE: Task or software timer?

Posted by Richard on February 27, 2012
“is my understanding correct”


No. I don't know where you have got that from.

The timer task stack is set by configTIMER_TASK_STACK_DEPTH and is specified in words, just like any other task. It should not be set below configMINIMAL_STACK_SIZE, and in fact even that might be too small.

Regards.

RE: Task or software timer?

Posted by Paul Coleman on February 27, 2012
But configMINIMAL_STACK_SIZE is hash defined as 256 in the config header file? And in the documentation for the function xTaskreate() it says that the stack size is the number of words not the number of bytes?

Regards, Paul.

RE: Task or software timer?

Posted by Richard on February 27, 2012
What you originally stated was:

“I noticed that even if you create a stack size of 1 the OS will set a minimum stack size of 256”


...and that is not correct. The OS will set whatever you set configTIMER_TASK_STACK_DEPTH to.

256 sounds like a large minimal stack value - which port are you using? Check the setting in the official demo for the port as it could well be smaller.

Regards.

RE: Task or software timer?

Posted by Paul Coleman on February 27, 2012
Okay thanks, will do.

Regards, Paul.

RE: Task or software timer?

Posted by Paul Coleman on February 27, 2012
Looking back it seems as though I got the stack size of 256 from one of the examples and never changed it. The demo for my port (AVR32) has a size of 128. Was I right in saying that's words not bytes though?

Is a task's stack used purely for local variables and any parameters passed into that task or does the OS use it behind the scenes? I'm just trying to get a feel for what size I should make it.

I know there are some hooks that I can implement to monitor the stack size which I'll do in the future.

Thanks, Paul.


[ 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