christiandy
                   
                   
                   
                  Joined: 03 Mar 2011 
                  Posts: 25 
                  Location: 101
                    | 
                
                  
                  
                  hi there,
 
I'm learning a scheduler with round robin algorithm module with two task and 55 ms quantum using system interrupt.
 
I have a problem when the task B running, it won't back to task A
 
here's the code
     
sched:   push ebx
    push ecx
                mov [tss_esp0],esp
; LOAD USER REGS
              lea esp,[ebx]
               popa
                pop ds
              pop es
              pop fs
              pop gs
              iret
      
here's the isr for interrupt 20 (sys timer)
     
push gs
          push fs
             push es
             push ds
             pusha
               lea esi,[sch_msg]
           call wrstr
; reset 8259 interrupt controller
     push  eax
   mov   al,0x20
       out   0xa0,al
       out   0x20,al                                   ; quiet screaming irq chip.
 pop   eax
; SAVE USER REGS
               mov ax,ss
           mov ds,ax
           mov es,ax
           mov fs,ax
           mov gs,ax
           lea esi,[esp]
               mov edi,[esp + 72]      ; saved kernel EBX -> user regs
          mov ecx,17              ; 17 dwords worth (68 bytes)
                rep movsd
           add esp,68
; LOAD KERNEL REGS
    pop ecx
     pop ebx
; reschedule
     cmp ebx,regsA
       je next
     lea ebx,[regsA]
     jmp again
next:  lea ebx,[regsB]
again:   jmp sched
; print ending msg
     lea esi,[end_msg]
   call wrstr
      jmp $
 
taskA:        lea esi,[hi_msgA]
   int 0x30                ; wrstr syscall
     a:
      mov ecx,0x7fffff
    ai:
     loop ai
     jmp a 
taskB:        lea esi,[hi_msgB]
   int 0x30                ; wrstr syscall
     b:
      mov ecx,0x7fffff
    bi:
     loop bi
     jmp b
       
tss and regs
tss:    dw 0, 0                 ; back link
tss_esp0:
        dd 0                    ; ESP0
      dw SYS_DATA_SEL, 0      ; SS0, reserved
     dd 0                    ; ESP1
      dw 0, 0                 ; SS1, reserved
     dd 0                    ; ESP2
      dw 0, 0                 ; SS2, reserved
     dd 0                    ; CR3
       dd 0, 0                 ; EIP, EFLAGS (EFLAGS=0x200 for ints)
       dd 0, 0, 0, 0           ; EAX, ECX, EDX, EBX
        dd 0, 0, 0, 0           ; ESP, EBP, ESI, EDI
        dw 0, 0                 ; ES, reserved
      dw 0, 0                 ; CS, reserved
      dw 0, 0                 ; SS, reserved
      dw 0, 0                 ; DS, reserved
      dw 0, 0                 ; FS, reserved
      dw 0, 0                 ; GS, reserved
      dw 0, 0                 ; LDT, reserved
     dw 0, 0                 ; debug, IO perm. bitmap
        times 63 dd 0
stackA:    dd 0
; regs popped by popa (ESP is popped and discarded)
regsA:       dd 0, 0, 0, 0, 0, 0, 0, 0       ; EDI, ESI, EBP, EBX, EDX, ECX, EDX
; regs popped by pop ds, etc.
regsA1:     dw USER_DATA_SEL, 0             ; DS
        dw USER_DATA_SEL, 0             ; ES
        dw USER_DATA_SEL, 0             ; FS
        dw USER_DATA_SEL, 0             ; GS
; regs popped by iret
regsA2:    dd taskA                        ; EIP
       dw USER_CODE_SEL, 0             ; CS
        dd 0x200                        ; EFLAGS (0x200 enables ints)
       dd stackA                       ; ESP
       dw USER_DATA_SEL, 0             ; SS
regsA3:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;      taskB data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        times 63 dd 0
stackB:    dd 0
regsB:      dd 0, 0, 0, 0, 0, 0, 0, 0
regsB1:        dw USER_DATA_SEL, 0
 dw USER_DATA_SEL, 0
 dw USER_DATA_SEL, 0
 dw USER_DATA_SEL, 0
regsB2:      dd taskB
    dw USER_CODE_SEL, 0
 dd 0x200
    dd stackB
   dw USER_DATA_SEL, 0
regsB3:
      
actually this is Christopher Giese <geezer[AT]execpc.com> protected mode module and i just modify it and it won't work
 
the output in this program is [hi_msgA] sched_msg hi_msgB sch_msg sch_msg and so on  
                  
                 |