1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2025-01-16 01:31:09 +00:00

Add count of active fibers

This commit is contained in:
dschmenk 2023-02-28 12:57:49 -08:00
parent c39fd20746
commit f5efc5641e
3 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import fiber
predef fbrInit(numPool), fbrStop(fid)#0, fbrExit#0, fbrStart(defaddr, param)
predef fbrYield#0, fbrHalt#0, fbrResume(fid)#0
byte fbrCount
end

View File

@ -19,6 +19,7 @@ byte fbrNext[MAX_FIBERS]
word fbrVMState[MAX_FIBERS]
word fbrPool
byte fbrRunning = 0
export byte fbrCount = 0
//
// Zero Page VM state and 6502 stack
//
@ -136,6 +137,7 @@ export def fbrInit(numPool)
else
return -1
fin
fbrCount = 1
return 0
end
//
@ -151,6 +153,7 @@ export def fbrStop(fid)#0
//
// Remove fiber from RUN list and tag as free
//
fbrCount--
fbrState[fid] = FIBER_FREE
i = 0
while fbrNext[i] <> fid
@ -212,6 +215,7 @@ export def fbrStart(defaddr, param)
//
// Return fiber ID (index)
//
fbrCount++
return i
fin
next

View File

@ -19,6 +19,5 @@ fbrInit(4)
fbrStart(@fbrTest, 3)
fbrStart(@fbrTest, 2)
fbrStart(@fbrTest, 1)
fbrYield; fbrYield; fbrYield; fbrYield
while fbrCount > 1; fbrYield; loop
done