A gos port for 6502.
A preemprive realtime scheduler, a micro-OS.
Idea: Time slices. A timer interrupts the currently running program. I then selectes another task
- Only
gos.c/hneeded (well,compiler.halso). - 4 compilers supported: cc65, oscar64, llvmmos, gate.
- baremetal ! Rom areas on C64 are set to ram !
Very minimal/tivial, only: core:
void (*GosFunc)(void);- create up to GOS_MAX_TASKS functions which run in parallelenum GosPrio;- each function has a time slice to run, higher prios = longer runs
void gosCreate(GosFunc f, GosPrio prio);- register a task; sculpt its stack to return into f after RTI, prio = tick intervalvoid gosStart(void);- install the IRQ vector and begin scheduling; never returns
INTERRUPT void gosIrq(void)- timer irq which switches tasks
optional:
void gosSwitch(void);- yield (optional)gosEnter/LeaveCS()- secure your stuff
problems: The 6502 was never designed for multitasking. Just one more opcode, e.g. "LDS #<page,default=1>" to set the stack page would have been so useful here. However, we have 256 bytes hw-stack all tasks have to share now, so normally 8 tasks with 32 bytes of stack (or 16/16).
compiler.hsupport for cc65, oscar64, llvmmos and gategos.hgos.c
...
GOS is integrated into my basic compiler:
10 REM! GOS
20 GOTASK 100
30 PRINT CHR$(205.5+RND(1));:GOTO 30
100 PRINT CHR$(19);TI$:YIELD:GOTO 100