Thread Dispatch via Interrupts

Chris Johns chrisj at rtems.org
Wed Apr 29 10:51:20 UTC 2009


Sebastian Huber wrote:
> Hi,
> 
> a common task of interrupt handlers is to do a thread dispatch after the actual
> interrupt processing.  On many architectures this is done in assembler code
> which lead recently to problems due to a data type size change, see also
> 
> https://www.rtems.org/bugzilla/show_bug.cgi?id=1385
> 
> On PowerPC we where not affected by this kind of problems, since we use this:
> 
> void _ISR_Thread_dispatch(void)
> {
>   if (_Context_Switch_necessary) {
>     _Thread_Dispatch();
>   } else if (_ISR_Signals_to_thread_executing) {
>     _ISR_Signals_to_thread_executing = false;
>     if (
>       _Thread_Do_post_task_switch_extension
>         || _Thread_Executing->do_post_task_switch_extension
>     ) {
>       _Thread_Executing->do_post_task_switch_extension = false;
>       _API_extensions_Run_postswitch();
>     }
>   }
> }
> 
> We should add this or a similar function to the super core.
> 
> The ARM and m68k for example the thread dispatch is not done in this way. Is
> there a reason for this?
> 

The code you provided is not the same logic as the m68k. It does not handle 
_Thread_Do_post_task_switch_extension. I wonder if it should.

Where do the stacks get managed in the C version ?

The m68k has a range of different stack hardware to support. The Coldfire 
supports stack switching in the ISR, the 68020 and similar devices support 
separate stacks and require a dummy stack frame be inserted into the ISR's 
stack so the return from interrupt returns the task's stack where 
_Thread_dispatch is called.

It is nice to see gcc and hand coded assembler almost agree on the 
instructions each uses.

Regards
Chris

> Have a nice day!
> 



More information about the users mailing list