This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: interrupt_end( ) compilation question.


On Tue, 2002-10-08 at 03:56, Qiang Huang wrote:
> Hi:
>     I got a question about the interrupt_end( ):
> when a thread is switched to another thread due to the interrupt happens as
> following:
> thread1 executes --> interrupt happens --> interrupt handler -->
> interrupt_end( ) --> HAL_THREAD_SWITCH_CONTEXT --> thread 2 executes.
> will it be possible that inside interrupt_end( ) function it use any
> register(after compiled to assembly code), if so will the execution
> context(thread1's) be lost?
> 
> for example:
> thread1:
> (1).	mov r1,0
> (2).	mov r2,1
> (3).	add r1,r2
> 
> if interrupt happens before line (2) , after line (1)[r1 already been set to
> 0], then whether when compiling interrupt_end( ) functioin r1 register will
> be used inside interrupt_end( ) or not? if so r1 = 0 previously will be
> lost, because HAL_THREAD_SWITCH_CONTEXT is executed inside interrupt_end is
> called.

If that happened, then the interrupt sequence would be badly
broken!  The process of taking an interrupt, processing it,
possibly changing threads and finally returning control to
the point where the interrupt occurred must be such that
there is *no loss* of context.  All registers, machine state,
etc, must be preserved.

The fact that the interrupt VSR code uses some registers should
not confuse you.  All of the user's registers will be saved on
the user's stack and restored when that thread is allowed to
continue.

-- 
------------------------------------------------------------
Gary Thomas                  |
eCosCentric, Ltd.            |  
+1 (970) 229-1963            |  eCos & RedBoot experts
gthomas@ecoscentric.com      |
http://www.ecoscentric.com/  |
------------------------------------------------------------


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]