Post by NicolaPost by Antoine Vignau...and offers a preemptive kernel.
That looks like a great project!
Can you elaborate a bit on how "preemptive" works in this context?
I guess that process cooperation is needed anyway, without hardware
support.
Nicola
Previous Kernel versions were designed as cooperative.
BIN must be designed with 3 entry points : INIT,RUN;QUIT. an optional entry point is EVENT if you want your BIN notified for TIMER events, for example.
the BIN/SBIN were responsible to give back control to kernel at the end of "RUN"
with CC if you want to be rentered at RUN by kernel or with CS and A=RC if you want to quit.
Additionally, a "SLEEP" API call is available if you want to "escape" a loop in your RUN code.
When preemptive mode is on, the kernel interrupt INIT/RUN/QUIT, and basically simulate a SLEEP call.
SLEEP save registers, 6502 ZP & HW stack on the process stack, and switch to another context, calling INIT,RUN,QUIT or RESUME (from SLEEP state) to next process in the list.
Every processes have :
a CS segment,relocatable code (includes initialized DATA)
a DS segment, uninitialized DATA
a SS segment, Stack segment for parameter passing....
a ZP context & PTRs : pPS, pCode, pData, pStack, pBase
Basically, every SBIN/BIN have been written to be "cooperative" and "preemtive" compliant.