Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GOS 6502

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/h needed (well, compiler.h also).
  • 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 parallel enum 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 interval void 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).

Files

  • compiler.h support for cc65, oscar64, llvmmos and gate
  • gos.h
  • gos.c

Tests

...

BASIC (c64)

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

About

a simple preemptive scheduler

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages