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 switch on 8051 - stack-copy overhead?

Posted by Mark on March 20, 2008
I am looking at FreeRTOS for an 8051 device. I was wondering how the task switch handles the stack. As I understand things the 8051 stack is limited to a single 256 byte memory space and so on a task switch everything has to copied out to / in from XDATA. That does not strike me as optimal (but hardly the OS's fault) and so are there some clever solutions FreeRTOS uses to get around it? Maybe it requires a modified 8051 that can map in XDATA to the stack space or something? Any advice and insight would be greatly appreciated.

Mark.

RE: Task switch on 8051 - stack-copy overhead?

Posted by woops_ on March 20, 2008
That is how the 8051 works its fixed, and by todays standard its not good. It was never designed to be use in larger applications so it is a shame the otherwise very nice Sil Labs parts use 8051.

RE: Task switch on 8051 - stack-copy overhead?

Posted by Mark on March 21, 2008
Thanks for the response. I kinda expected that would be the case. I guess that sometimes we forget that just adding memory and running at faster clock speeds doesn't solve everything. It doesn't make the 8051 a bad processor though - just defines a limit of what it can/should be used for.

RE: Task switch on 8051 - stack-copy overhead

Posted by David Hawks on March 21, 2008
Some of the more exotic devices have 16-bit stack pointers, but most 8051 variants are locked in to an 8-bit stack pointer. Not much an OS can do about that.

The 8051 FreeRTOS port copies the used portion of the internal stack to/from XDATA on a context switch. The stack copy adds a significant amount of overhead to a context switch. If you expect your application to use most of the processing power of the controller, you probably ought to look elsewhere. However, if you can handle the overhead, FreeRTOS on an 8051 works pretty nicely.

I use FreeRTOS on several SiLabs 8051 parts. I run the system clock at 100 MHz with a FreeRTOS tick rate of 1 kHz. The average context switch time is 42 us (worst case of 62 us with a full stack). This leaves a task with about 950 us of execution time (~95,000 cycles). In other words, my configuration has a context switch overhead of about 5%. My average processor utilization is under 50%, so I can afford the overhead.

Good Luck!

RE: Task switch on 8051 - stack-copy overhead?

Posted by Mark on April 14, 2008
Thanks for your answers - I have a clear picture of the issues now.


[ 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