mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-31 23:09:33 +00:00
194 lines
4.0 KiB
Plaintext
194 lines
4.0 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
LOMEM $A00
|
||
INC 1
|
||
AUTO 6
|
||
*--------------------------------------
|
||
* TSK.TskMgrRun
|
||
*--------------------------------------
|
||
TSK.TskMgrRun >LDYAI TskMgr.Table+S.PS skip PS 0
|
||
>STYA pPs
|
||
|
||
lda TskMgr.Count
|
||
sta TskMgr.Idx
|
||
|
||
.1 dec TskMgr.Idx skip PS 0
|
||
beq .8
|
||
|
||
lda (pPs) get S.PS.F
|
||
bit #S.PS.F.INUSE In use ?
|
||
beq .7
|
||
|
||
bit #S.PS.F.HOLD Waiting for Another Task to Terminate?
|
||
beq .2
|
||
|
||
ldy #S.PS.CPID
|
||
lda (pPs),y
|
||
jsr K.GetPSByIDA
|
||
bcc .7 yes, running....
|
||
|
||
lda (pPs) get S.PS.F
|
||
and #$FF^S.PS.F.HOLD unmark as HOLD
|
||
sta (pPs)
|
||
|
||
.2 jsr PS.Select
|
||
|
||
lda (pPS)
|
||
bit #S.PS.F.INIT
|
||
bne .30
|
||
|
||
bit #S.PS.F.SLEEP Is this PS sleeping?
|
||
beq .3 no, call TSKMGR.RUN
|
||
|
||
jsr TSK.PSWakeUp
|
||
bra .4
|
||
|
||
.30 and #$FF^S.PS.F.INIT unmark as INIT
|
||
sta (pPS)
|
||
|
||
ldx #TSKMGR.INIT
|
||
.HS 2C BIT abs
|
||
.3 ldx #TSKMGR.RUN
|
||
|
||
.31 jsr pCodeJmp Call INIT/RUN function
|
||
|
||
.4 bcc .7 INIT/RUN said CS=QUIT?
|
||
|
||
pha save RC
|
||
ldy #S.PS.PPID Notify Parent Process for exit code...
|
||
lda (pPs),y
|
||
jsr K.GetPSByIDA will set ZPPtr1 if success
|
||
bcs .5 parent is dead.....skipping...
|
||
|
||
lda (ZPPtr1) Parent PS is HOLD?
|
||
bit #S.PS.F.HOLD
|
||
beq .5 no...
|
||
|
||
eor #S.PS.F.HOLD yes, release hold...
|
||
sta (ZPPtr1)
|
||
|
||
pla ...probably waiting for this PS to terminate....
|
||
ldy #S.PS.RC give it RC
|
||
sta (ZPPtr1),y
|
||
|
||
.HS B0 BCS
|
||
.5 pla
|
||
|
||
.6 ldx #TSKMGR.QUIT yes, quit this process
|
||
jsr pCodeJmp Call QUIT function
|
||
|
||
ldy #S.PS.PID
|
||
lda (pPs),y
|
||
jsr PS.FreeA
|
||
|
||
.7 lda pPs
|
||
clc
|
||
adc #S.PS
|
||
sta pPs
|
||
bcc .1
|
||
inc pPs+1
|
||
bcs .1 Always
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
TSK.PSWakeUp 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 setup by PS.Select
|
||
sta .1+1
|
||
iny
|
||
lda (pPs),y
|
||
adc pCode+1
|
||
sta .1+2
|
||
|
||
.1 jmp $FFFF
|
||
*--------------------------------------
|
||
* TSK.DispatchEvents
|
||
* IN:
|
||
* OUT:
|
||
* CS: Not Dispatched
|
||
* CC: Event Cleared
|
||
*--------------------------------------
|
||
TSK.DispatchEvents
|
||
>LDYAI TskMgr.Table+S.PS
|
||
>STYA pPs
|
||
|
||
lda TskMgr.Count Number of actual processes...
|
||
sta TskMgr.Idx ...to give event list
|
||
|
||
.1 dec TskMgr.Idx skip PS 0
|
||
beq .9
|
||
|
||
lda (pPs) get S.PS.F
|
||
bpl .4
|
||
|
||
* bit #S.PS.F.INUSE In use ?
|
||
* beq .4
|
||
|
||
bit #S.PS.F.INIT+S.PS.F.HOLD Init or Waiting for Another Task to Terminate?
|
||
bne .4
|
||
|
||
bit #S.PS.F.EVENT Accept Events ?
|
||
beq .4
|
||
|
||
jsr PS.Select
|
||
|
||
lda #EvtMgr.Table
|
||
sta pEvent Select first event in list
|
||
|
||
lda EVTMGR.COUNT
|
||
sta TSKMGR.EVENTCNT
|
||
|
||
.2 lda (pEvent) Empty event, select next
|
||
beq .3
|
||
|
||
lda (pCode)
|
||
cmp #H.BIN.HEADER.BIN65
|
||
bne *
|
||
|
||
ldx #TSKMGR.DOEVENT
|
||
jsr pCodeJmp Call DOEVENT function
|
||
bcs .3 not for this PS, try next event in list
|
||
|
||
jsr EVT.DestroyEvent this PS handled the EVT, destroy it...
|
||
lda EVTMGR.COUNT
|
||
beq .8 no more event, exit
|
||
|
||
.3 dec TSKMGR.EVENTCNT
|
||
beq .4 all EVT submitted to this PS, try other PS
|
||
|
||
lda pEvent try next EVT to this PS
|
||
clc
|
||
adc #S.EVT
|
||
sta pEvent
|
||
bra .2
|
||
|
||
.4 lda pPs go to next PS in PS list
|
||
clc
|
||
adc #S.PS
|
||
sta pPs
|
||
bcc .1
|
||
inc pPs+1
|
||
bne .1 always
|
||
|
||
.8 clc
|
||
rts
|
||
|
||
.9 sec
|
||
rts
|
||
*--------------------------------------
|
||
TSK.TskMgrQuit clc
|
||
rts
|
||
*--------------------------------------
|
||
TskMgr.Idx .BS 1
|
||
TSKMGR.EVENTCNT .BS 1
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/SYS/KERNEL.S.TSK
|
||
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
||
ASM
|