Hacker News new | past | comments | ask | show | jobs | submit login

Maybe I'm missing something, but I can't see where it states that SymbOS provides preemptive multitasking. The facts page [1] states that "I want to give everything to SymbOS what a modern OS needs. Real preemptive Multitasking, a dynamic memory-management for up to 576K and more.", but thats not the same as it actually having it. I can't actually see how preemption would be possible on a Z80. Have I missed something?

CLiPS (on the same site) appears to support preemption [2], but that requires a C64. I don't know how that is achieved.

Very impressive work nevertheless.

[1] http://www.symbos.de/facts.htm

[2] http://www.symbos.de/mirrors/www.clips64.de/details.htm




Page http://www.symbos.de/facts.htm, end of the third paragraph "Real preemptive Multitasking, a dynamic memory-management for up to 576K and more and a totaly MS-Windows-like GUI are the three most important things."

I'm also a little puzzled about real preemption on a Z80, but http://www.cpcwiki.eu/index.php/SymbOS#Technical_background states

"Even the Z80 8-bit CPU is able to run a pre-emptive multitasking environment. Missing mechanisms like memory protection, which are often called as a condition for multitasking, are system stability issues only. The MP/M operating system already proved, that multitasking on Z80 computers is possible.

While the MOS Technology 6502 can not move the stack, the Z80 can freely replace it to any position in the memory, which is more or less a condition for pre-emptive multitasking. The existance of an alternative register set accelerates the content switching between the tasks dramatically. The restriction of Z80 systems to a 64 kB address space can be solved with bank switching. In this way computers like the Amstrad CPC and PCW, MSX, Enterprise or SAM Coupé are able to access hundred or thousand of kilobytes of memory. "


Page http://www.symbos.de/facts.htm, end of the third paragraph "Real preemptive Multitasking, a dynamic memory-management for up to 576K and more and a totaly MS-Windows-like GUI are the three most important things."

The previous sentence is "I want to give everything to SymbOS what a modern OS needs.", so I read that as being a statement of what the developer wants the OS to have in the future.

Further down the page, in the details section, it states "Priority based preemptice [sic] and cooperative multitasking" is done. Wikipedia mentions that a combination of preemptive and cooperative task management is used [1]. I'm confused.

(And just to be clear: I'm not trying to be negative. I'm very impressed with the technology and tenacity of the author.)


I'm not sure preemptive multitasking is a good idea for a Z80 anyway. You can either run one program slowly, or two at a snail's pace.

At least it can address enough memory to make it not a complete waste.


Preemption just means the task is stopped when its timeslice elapses, and a new task selected. You can do this on any CPU with a regular timer interrupt. On something like the ZX Spectrum you'll need to use the vblank interrupt; on something with a programmable timer, you can make the timing tighter.

(In either case, you'll probably want some mechanism for tasks to relinquish their timeslice early; no reason not to make multitasking run better when tasks cooperate, even if it doesn't absolutely require that.)

To do the actual task switch, do exactly what you do on any system:

- save register state in tasks's register area (the state will be available on entry to the interrupt routine, in the usual fashion. The task pointer will be a system global at a fixed address)

- set timer for one timeslice hence (timers probably count down to zero, so this will just be a question of putting a value somewhere into an I/O register)

- resumes task by jumping to the program counter value from the task's register area

- GOTO 10...

(The complications come on something like the 6502, which has a fixed-size, fixed-address stack - but this it hard task-switching difficult, not the preemption! How I imagine CLIPS gets around this: it requires CMD SuperCPU, which is a 65816. Like the Z80 and 6809, but unlike the 6502, the 65816 has a relocatable stack. So it will probably behave as I describe above.)


816 has a relocatable stack and direct(nee zero) page, so that's good. Unfortunately both of those still have to be in the lower 64k bank. So that's a bit frustrating for trying to write OS support for multitasking larger memory systems.


I don't know how symbios does it but I don't think it's that hard to create something pretty close to preemptive multitasking on a z80. You have the vsync interrupt (50 times per second). Add to that some stack manipulation, some bookkeeping and a register store/restore procedure and you're done. It wouldn't be fast though, and it would also limit what a process is allowed to do (disable interrupt, write outside of its own memory region). The z80 provides no mechanism to enforce this, of course. But technically, it's a primitive kind of preemptive multitasking.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: