QDOS Internals

Scheduler disassembly by Dave Westbury

THE SCHEDULER

00936  jsr       $000009D4(PC)          save current job/check JB.PRIOR
0093A  move.w    $0030(a6),d3           get lost polls, SV.POLLM
0093E  clr.w     $0030(a6)              zero SV.POLLM
00942  addq.w    #$01,$002E(a6)         increment SV.RAND
00946  moveq     #-$10,d0               link offset
00948  movea.l   $0040(a6),a0           SV.SHLST
0094C  jsr       $00000A9E(PC)          do scheduler task list
                                        ie; $120A flash cursor
                                            $2D14 as transmit interrupt
                                            $3488 do waiting I/O
00950  jsr       $00000A0C(PC)          do job table
00954  tst.l     d0                     d0=-2 if no active job!
00956  blt.s     $0000093A              try again...
00958  move.l    d0,$0064(a6)           update SV.JBPNT to new job
0095C  jsr       $00000A78(PC)          rte by restore to next active job
00960  jsr       $000003BC(PC)
00964  move.w    d3,$0014(a0)
00968  move.l    a1,$000C(a0)
0096C  moveq     #$00,d0
0096E  bra       $00000936

* Save current job details
009D4  move.l    a6,-(a7)
009D6  movea.l   $0064(a6),a6           SV.JBPNT current job table entry
009DA  movea.l   (a6),a6                current job header
009DC  tst.b     $0012(a6)              JB.PRIOR current job
009E0  beq.s     $000009E8              branch if 0
009E2  move.b    #$01,$0012(a6)         else reduce to 1
009E8  movem.l   d0-d7/a0-a4,$0020(a6)  save jobs registers
009EE  move.l    (a5)+,$003C(a6)        d7
009F2  move.l    (a5)+,$0054(a6)        a5
009F6  move.l    (a5)+,$0058(a6)        a6
009FA  move      USP,a0
009FC  move.l    a0,$005C(a6)           a7=USP
00A00  move.w    (a5)+,$0060(a6)        SR
00A04  move.l    (a5)+,$0062(a6)        PC
00A08  movea.l   (a7)+,a6               Restore a6 with $28000
00A0A  rts

* Go through job table
00A0C  moveq     #-$02,d0               nul job table entry return code
00A0E  moveq     #$00,d1                highest JB.PRIOR found
00A10  movea.l   $0064(a6),a2           SV.JBPNT current job entry
00A14  movea.l   a2,a4
00A16  move.w    $0062(a6),d2           SV.JBMAX highest ever job no.
00A1A  lsl.w     #$02,d2
00A1C  movea.l   $0068(a6),a3           SV.JBBAS base of job table
00A20  adda.w    d2,a3                  a3 = table entry SV.JBMAX
00A22  addq.w    #$04,a2                next table entry
00A24  cmpa.l    a3,a2
00A26  ble.s     $00000A2C              do each entry till top
00A28  movea.l   $0068(a6),a2           then wrap round to base
00A2C  tst.b     (a2)
00A2E  blt.s     $00000A72              branch if job invalid, 'FF000000'
00A30  movea.l   (a2),a0                get job header
00A32  tst.b     $0013(a0)              JB.PRINC
00A36  beq.s     $00000A72              if inactive (=0) ignore, get next
00A38  tst.w     $0014(a0)              JB.STAT
00A3C  beq.s     $00000A54              branch if active (=0)
00A3E  blt.s     $00000A72              if suspended or waiting, get next
00A40  sub.w     d3,$0014(a0)           else deduct lost polls SV.POLLM
00A44  bgt.s     $00000A72              if frames left, do next job
00A46  clr.w     $0014(a0)              else timeout expired
00A4A  move.l    $000C(a0),d2           JB.HOLD
00A4E  beq.s     $00000A54              branch if no location to clear
00A50  movea.l   d2,a1
00A52  sf        (a1)                   clear job waiting flag location

00A54  move.b    $0012(a0),d2           ; if JB.PRIOR = 0, set to 1
00A58  beq.s     $00000A64              ; else add JB.PRINC 
00A5A  add.b     $0013(a0),d2           ;    if >255 set to 255
00A5E  bcc.s     $00000A66              ;    else set to result
00A60  st        d2                     ;
00A62  bra.s     $00000A66              ;
00A64  moveq     #$01,d2                ;
00A66  move.b    d2,$0012(a0)           Update JB.PRIOR
00A6A  cmp.b     d1,d2                  highest JB.PRIOR to this JB.PRIOR
00A6C  bls.s     $00000A72              if not higher branch
00A6E  move.l    a2,d0                  highest job table entry to d0
00A70  move.b    d2,d1                  this now highest JB.PRIOR
00A72  cmpa.l    a4,a2                  done all entries in job table ?
00A74  bne.s     $00000A22
00A76  rts

* Restore to next job
00A78  movea.l   $0064(a6),a0           SV.JBPNT
00A7C  movea.l   (a0),a0
00A7E  adda.w    #$0016,a7              reset SSP stack
00A82  move.l    $0062(a0),-(a7)        JB.PC to SSP
00A86  move.w    $0060(a0),-(a7)        JB.SR to SSP
00A8A  move.l    $001C(a0),$0050(a6)    JB.TRAPV to SV.TRAPV
00A90  movea.l   $005C(a0),a1           JB.A7 
00A94  move      a1,USP
00A96  movem.l   $0020(a0),d0-d7/a0-a6  get jobs previous regs back
00A9C  rte

* Do linkage block list
00A9E  move.w    d0,-(a7)               stack offset
00AA0  movea.l   a0,a3                  link block base address
00AA2  adda.w    (a7),a3                set up a3 to link with offset
00AA4  move.l    a0,-(a7)               stack current link address
00AA6  beq.s     $00000ABC              empty or finished list ?
00AA8  move.w    d3,-(a7)               stack current flag (?)
00AAA  andi.w    #$007F,d3              mask flag (?)
00AAE  movea.l   $0004(a0),a0           get link start address
00AB2  jsr       (a0)                   go do link routine
00AB4  move.w    (a7)+,d3               restore flag (?)
00AB6  movea.l   (a7)+,a0               restore last link done
00AB8  movea.l   (a0),a0                address of next link
00ABA  bra.s     $00000AA0              do next link
00ABC  addq.l    #$06,a7                clear stack
00ABE  rts
Back to QDOS Internals