XRAM on 8051

nobody wrote on Wednesday, December 22, 2004:

Very much pleased to see u r  FREERTOS  .  Very much interesting to learn. ok  In the port 8051  u r using  Xram  for context switch. ,Can i use internal instead of external ram.  How to find  what r the registers involved  for context swiching  for particular  device and particular compiler. how to find out   writing sample program for that device and compiler pl give example and to learn things

rtel wrote on Wednesday, December 22, 2004:

The stack for a task uses the internal RAM when the task is executing.  This is dictated by the architecture of the device, but is also good as the internal RAM can be accessed much faster than the external.

However, the internal RAM is much to small to hold the context of all the tasks, so the context of all the tasks that are not currently executing has to be in XRAM.  A context switch therefore has to save from internal to XRAM, then copy from XRAM to internal.

As far as finding out which registers are required to be saved and restored - the internal architecture of any device has to be learned from the device datasheets.  This will describe all the registers.  This together with examining your chosen compilers output will allow you to ascertain which registers are used when, and which form part of the context.  Generally all general purpose registers should be saved.