SPARC Context Switch Code

Sebastian Huber sebastian.huber at embedded-brains.de
Thu Feb 6 12:45:22 UTC 2014


On 2014-02-06 13:17, Ingolf Steinbach wrote:
> 2014-02-06 Sebastian Huber <sebastian.huber at embedded-brains.de>:
>> Why do you think that _CPU_Context_switch() is invoked at arbitrary places?
>>
>> The only valid invocation places for _CPU_Context_switch() are
>> _Thread_Dispatch() and _Thread_Start_multitasking().
>
> Isn't _Thread_Dispatch() used within the Clock ISR?

The _Thread_Dispatch() function is used in the interrupt epilogue.  For example

http://git.rtems.org/rtems/tree/c/src/lib/libbsp/sparc/shared/irq_asm.S#n610

> My impression
> (which might be wrong) was that the _CPU_Context_switch() is used
> there when switching execution to another task/thread.

Yes, this function switches the execution from on thread to another.

> This switch
> could happen at arbitrary places (in the interrupted task).

Interrupts cannot happen at arbitrary places.  Interrupts can happen when 
interrupts are enabled.

The interrupt prologue and epilogue code must take care about the interrupted 
context.  This is done usually in two steps.  The first step is performed by 
the processor and the second step is some code that saves/restores the rest of 
the volatile context.  This has nothing to do with the _CPU_Context_switch() 
function.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the users mailing list