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

x86, InitialiseStack and FIRST_CONTEXT

Posted by Tim Lewis on June 5, 2012
So I am working on a native x86 port (both 32-bit and x64) and am not clear on what should be on the task stack in InitialiseStack. In particular, which stack frame am I trying to create? In this particular case, I cannot use an interrupt to do the yield (because this port will also be run in a hosted environment where software INTs are restricted), so I'll be using a CALL (no in-line assembly for the 64-bit Visual Studio compiler).

I started by copying the 16-bit DOS port and am very familiar with that environment.

Also, what is the traditional stance on saving/restoring floating-point regs? Don't use? Flag as being used? Flag when first FP exception occurs? Always save? The current Windows emulator port avoids this by using Windows threads.

Thanks, Tim

RE: x86, InitialiseStack and FIRST_CONTEXT

Posted by Richard on June 5, 2012
Interesting. So is this to run bare metal on the X86? The windows simulator is just that, it runs the FreeRTOS scheduler and allows that to select which tasks to run when depending on their priority, but when the scheduler itself runs is still ultimately under the control of Windows as it runs in a Windows thread. Hence the very non real time performance. It is a great development and test bed, but not a port in itself.

There is no real fixed way of performing the floating point switching. The obvious way is to save and restore all the time for every task. A more efficient way to allow tasks to register their interest in the floating point context, and then only do it for those tasks (often into a separate array, rather than onto the stack). The most efficient way, if only a few tasks are using the FPU, is to turn the FPU off, and then do the context switching (and re-enabling) of the FPU in the exception that occurs when a task actually tries to use a floating point instruction. I'm not familiar enough to with the x86 to know if that last way is even possible - but I think it is how Linux does it so I'm guessing it must be.

There are trade offs to each of the FPU saving techniques, and which is best depends on how many tasks are accessing the FPU, and how often those tasks actually use the FPU.

Regards.

RE: x86, InitialiseStack and FIRST_CONTEXT

Posted by Tim Lewis on June 5, 2012
It is designed to run bare-metal and in a very specialized hosted environment. The only difference in them is how the timer tick gets delivered.


[ 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