mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
161 lines
2.9 KiB
Plaintext
161 lines
2.9 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* S.TskMgrRun
|
||
*--------------------------------------
|
||
S.TskMgrRun >LDYAI TskMgr.Table+S.PS.SIZE
|
||
>STYA pPs
|
||
|
||
lda TSKMGR.SIZE
|
||
sta TSKMGR.COUNT
|
||
|
||
.1 dec TSKMGR.COUNT skip PS 0
|
||
beq .8
|
||
|
||
lda (pPs) get S.PS.F
|
||
bit #S.PS.F.INUSE In use ?
|
||
beq .5
|
||
|
||
bit #S.PS.F.HOLD Waiting for Another Task to Terminate?
|
||
beq .2
|
||
|
||
ldy #S.PS.CID
|
||
lda (pPs),y
|
||
jsr S.GetPSByIDA
|
||
bcc .5 yes, running....
|
||
|
||
lda (pPs) get S.PS.F
|
||
and #$FF^S.PS.F.HOLD unmark as HOLD
|
||
sta (pPs)
|
||
|
||
.2 jsr S.SelectProcess
|
||
|
||
lda (pPS)
|
||
bit #S.PS.F.SLEEP Is this PS sleeping?
|
||
beq .3 no, call TSKMGR.RUN
|
||
|
||
and #$FF^S.PS.F.SLEEP unmark as SLEEP
|
||
sta (pPS)
|
||
|
||
ldy #S.PS.PC
|
||
lda (pPs),y
|
||
sec Advance PC by one as it was saved by a JSR
|
||
adc pCode
|
||
sta .21+1
|
||
iny
|
||
lda (pPs),y
|
||
adc pCode+1
|
||
sta .21+2
|
||
|
||
.21 jsr $FFFF
|
||
bra .4
|
||
|
||
.3 ldx #TSKMGR.RUN
|
||
jsr pCodeJmp Call RUN function
|
||
.4 bcc .5 RUN said CS=QUIT?
|
||
|
||
ldx #TSKMGR.QUIT yes, quit this process
|
||
jsr pCodeJmp Call QUIT function
|
||
|
||
ldy #S.PS.ID
|
||
lda (pPs),y
|
||
jsr S.FreeProcessA
|
||
bcs *
|
||
|
||
.5 lda pPs
|
||
clc
|
||
adc #S.PS.SIZE
|
||
sta pPs
|
||
bcc .1
|
||
inc pPs+1
|
||
bne .1
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
* S.DispatchEvent
|
||
* IN:
|
||
* OUT:
|
||
* CS: Not Dispatched
|
||
* CC: Event Cleared
|
||
*--------------------------------------
|
||
S.DispatchEvents
|
||
>LDYAI TskMgr.Table+S.PS.SIZE
|
||
>STYA pPs
|
||
|
||
lda TSKMGR.SIZE
|
||
sta TSKMGR.COUNT
|
||
|
||
.1 dec TSKMGR.COUNT skip PS 0
|
||
beq .9
|
||
|
||
lda (pPs) get S.PS.F
|
||
bit #S.PS.F.INUSE In use ?
|
||
beq .4
|
||
|
||
bit #S.PS.F.HOLD Waiting for Another Task to Terminate?
|
||
bne .4
|
||
|
||
bit #S.PS.F.EVENT Accept Events ?
|
||
beq .4
|
||
|
||
jsr S.SelectProcess
|
||
|
||
stz pEvent
|
||
|
||
lda EVTMGR.SIZE
|
||
sta TSKMGR.EVENTCNT
|
||
|
||
.2 lda (pEvent)
|
||
beq .3
|
||
|
||
lda (pCode)
|
||
cmp #H.BIN.HEADER.BIN65
|
||
bne *
|
||
|
||
ldx #TSKMGR.DOEVENT
|
||
jsr pCodeJmp Call DOEVENT function
|
||
bcs .3
|
||
jsr S.DestroyEvent
|
||
lda EVTMGR.COUNT
|
||
beq .8
|
||
|
||
.3 dec TSKMGR.EVENTCNT
|
||
beq .4
|
||
lda pEvent
|
||
clc
|
||
adc #S.EVT
|
||
sta pEvent
|
||
bra .2
|
||
|
||
.4 lda pPs
|
||
clc
|
||
adc #S.PS.SIZE
|
||
sta pPs
|
||
bcc .1
|
||
inc pPs+1
|
||
bne .1 always
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
S.TskMgrQuit clc
|
||
rts
|
||
*--------------------------------------
|
||
TSKMGR.SIZE .BS 1
|
||
TSKMGR.COUNT .BS 1
|
||
TSKMGR.EVENTCNT .BS 1
|
||
TSKMGR.LASTID .BS 1
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE SYS/KERNEL.S.TSK
|
||
LOAD SYS/KERNEL.S
|
||
ASM
|