This is my understanding( simplified )of task switch process:
1.An Idle Process is running
2.An time interrupt occur
3.Timer ISR saves current state(regs) to the stack.
4.Call timer handler
5.Timer handler call schedule();
6.schedule() choose another task (TASK_A )to run.
<Suppose TASK_A is doing a infinite loop.It does not stop until another timer interrupt occur.>
7.Goto step 2.
Here is my question:
Since TASK_A never returns , who is responsible to pop the registers pushed to stack in step 3?
If we don't pop those registers ,the stack will overflow very soon.
Where did I misunderstand ?
P.S: The timer ISR->
Code: Select all
isr:
push byte 0 ; ( 0) fake error code
PUSHB %1 ; ( 2) exception number
push gs ; ( 4) push segment registers
push fs ; ( 6)
push es ; ( 8)
push ds ; ( 9)
pusha ; (10) push GP registers
mov ax,gdt_data_addr ; (11) put known-good values...
mov ds,eax ; (15) ...in segment registers
mov es,eax ; (17)
mov fs,eax ; (19)
mov gs,eax ; (21)
mov eax,esp ; (23)
push eax ; (25) push pointer to regs_t
.1:
mov eax,_timer_interrupt; (26)
call eax ; (31)
;**************************************************
;When the following code been executed?
;**************************************************
pop eax
popa ; pop GP registers
pop ds ; pop segment registers
pop es
pop fs
pop gs
nop
nop
add esp,8 ; drop exception number and error code
iret