Re: Question about interrupt in MINIX3
- From: Vietory <pn.truongphuc@xxxxxxxxx>
- Date: Tue, 18 Sep 2007 03:23:01 -0000
On Sep 18, 9:43 am, waqar.pa...@xxxxxxxxx wrote:
On Sep 17, 9:11 pm, Vietory <pn.truongp...@xxxxxxxxx> wrote:
On Sep 17, 3:20 pm, waqar.pa...@xxxxxxxxx wrote:
On Sep 15, 11:34 pm, Vietory <pn.truongp...@xxxxxxxxx> wrote:
"When the CPU receives an interrupt while running a process it sets up
a new stack for use during the interrupt service. The location of this
stack is determined by an entry in the Task State Segment (TSS). One
such structure exists for the entire system, initialized by cstart's
call to prot_init, and modified as each process is started. The effect
is that the new stack created by an interrupt always starts at the end
of the stackframe_s structure within the process table entry of the
interrupted process".
I don't understand why it said "new stack created by an interrupt
always start at the end of the stackframe_s structure within the
process table entry of the interrupted process", because if there is
another process entry in the process table right after the interrupted
process, the new stack will overlay that entry.
Can you explain me?
I greately appreciate your help!
The stackframe_s structure resides at the beginning of the process
table entry. When an interrupt occurs, the stack
pointer points to the last entry of the stackframe_s structure. As
register values are saved on the frame, the stack pointer
moves from the last entry to the first entry of the stack frame. When
all registers are saved the stack pointer points to the
first entry of the stack frame and is still inside the process table
entry of the interrupted process.
Well, I quite understand what you explain but some question still
remains for me. Look at the stackframe structure:
04956 struct stackframe_s { /* proc_ptr points here */
04957 #if _WORD_SIZE == 4
04958 u16_t gs; /* last item pushed by save
*/
04959 u16_t fs; /* ^ */
04960 #endif
04961 u16_t es; /* | */
04962 u16_t ds; /* | */
04963 reg_t di; /* di through cx are not
accessed in C */
04964 reg_t si; /* order is to match pusha/
popa */
04965 reg_t fp; /* bp */
04966 reg_t st; /* hole for another copy of
sp */
04967 reg_t bx; /* | */
04968 reg_t dx; /* | */
04969 reg_t cx; /* | */
04970 reg_t retreg; /* ax and above are all
pushed by save */
04971 reg_t retadr; /* return address for
assembly code save() */
04972 reg_t pc; /* ^ last item pushed
by interrupt */
04973 reg_t cs; /* | */
04974 reg_t psw; /* | */
04975 reg_t sp; /* | */
04976 reg_t ss; /* these are pushed by CPU
during interrupt */
04977 };
When interrupt occurs, CPU will fill the last 5 entries of stackframe,
then *save* function will fill the rest. When the interrupted process
has a chance to run, the *_restart* function will do the context
switch and use the _proc_ptr as the stack pointer to pop all the
register that *save* had been push. It also arrange for the next
interrupt to save state in process table by using some instruction:
06692 lea eax, P_STACKTOP(esp) ! arrange for next
interrupt
06693 mov (_tss+TSS3_S_SP0), eax ! to save state in
process table
Those's I know so far. I want to know: (1) does interrupt service just
use five last entries in stackframe as its stack? If not which stack
it use?
(2) Can you show me where the code CPU push five last entries?
I appreciate your help.
Thanks very much!
(1) does interrupt service just use five last entries in stackframe as its stack? If not which stack it use?
Before jumping over to the interrupt service, the kernel switches
its stack and sets the stack pointer to the
top of the "kernel stack". See line 6635 in save(). The kernel
stack is ment to serve as a stack space when
interrupt services are running. Its space is reserved in the
kernel data section. See line 6828 in mpx386.s.
(2) Can you show me where the code CPU push five last entries?
The last five entries are not pushed by assembly instructions so
you won't find them anywhere in the code.
Pushing these five registers is "hardwired" into the cpu.
I understand now about the interrupt mechanism, but still doubt about
the line "new stack created by an interrupt always start at the end of
the stackframe_s structure within the process table entry of the
interrupted process". New stack created by an interrupt is the last
five entries?
I appreciate your help.
Thanks very much!
.
- References:
- Question about interrupt in MINIX3
- From: Vietory
- Re: Question about interrupt in MINIX3
- From: waqar . paxym
- Re: Question about interrupt in MINIX3
- From: Vietory
- Question about interrupt in MINIX3
- Prev by Date: Re: Help!Minix can't be installed in my Vmware workstation
- Next by Date: Re: Minix Case Study?
- Previous by thread: Re: Question about interrupt in MINIX3
- Next by thread: MINIX3 and Gnome/KDE
- Index(es):
Relevant Pages
|
Loading