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:
parent
c39fd20746
commit
f5efc5641e
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user