Date : Wed, 22 Aug 1990 12:44:07 GMT
From : mcsun!hp4nl!sci.kun.nl!cs.kun.nl!lwj@uunet.uu.net (Luc Rooijakkers)
Subject: Z80 multitask
jurjen@cwi.nl (Jurjen NE Bos) writes:
>clldomps@praxis.cs.ruu.nl (Louis van Dompselaar) writes:
>>Is there anyone who has had some experience in using multitasking
>>on a Z80 system? Please let me know what is, and what is not, possible...
>Easy! We (4 friends and me) built a multi-user Z80 systems already years
>ago, featuring 512K RAM, two real floppy drives while the users thought
>they had 4 floppies each (but if you wanted to read something, you had to
>walk over and insert your floppy), 5 terminals, etc.
>The system is still running, and today they are working on a LAN, hard disk,
>and more goodies.
>The trick is to get some coprocessors for things like key scanning, disk I/O,
>and other work that tends to eat away cycles. The CPU can then start doing
>only the more useful things. But of course, we had a lot more performance-
>increasing tricks...
But not too many. Since I'm the creator of the Timesharing software for
that machine (Hi Jurjen!), I will give some hints. By the way, the
software is still in use and amounts to about 12,000 lines assembly language
(when I last counted it about a year ago).
Basically, it all boils down to avoiding busy-waiting like the plague.
So ALL I/O devices have to be interrupt-driven, and in our environment
CP/M programs that constantly sit in a console-status loop are frowned
on. Unfortunately, there are quite a lot of these (WordStar, among
others, though we don't use it very much).
We run multiple CP/M 2.2 systems on the system, with a *big* BIOS that
does the sharing and lots of other work. The users each have 4 drives
which they can assign to any named disk. When needed, the system asks
for the disks, which can then be plugged in in any disk drive. We also
support the use of two 5M ST506 hard disks (very old PC hard disks) which
are attached to another Z80 system with a SASI adapter. The two systems
communicate over our own home-built 500Kbit/s token bus network (built
with Z80 SIO chips). The system uses about 100K for disk caching, since
we have plenty of memory.
It might be worth saying that we started this project back in 1984. The
system still works very satisfactory and is in daily use.
As a matter of fact, our system averages about 80 percent *idle* time.
Humans are just too slow to keep any computer busy. Of course, when you
start running more than one CPU-intensive application (like an
assembler, or a compiler) then they each get their share of the
available CPU time, proportional to the number of running programs. But
other I/O-intensive programs like text editors do not suffer from this
very much.
We did add a little bank switching logic external to the Z80, but that
was not really difficult. It basically consists of a 16 byte memory
that translates address lines A12 to A15 from the Z80 to address lines
A12 to A18 on the bus (the 8th bit is used for write protect). For
hardware freaks, these were just two 7485 chips and a few buffers.
One thing not possible with our setup is a *secure* multi-user environment,
but we didn't need that. You can do this using the more modern Z280 chip,
which has the MMU built on-chip (with 3 DMA-controllers and 256 bytes of
cache memory and lots of other goodies). The instruction set is upward
compatible with the Z80, and has nice additions like divide and multiply
instructions and lots of new adressing modes (e.g. LD HL,(SP+n) ). In fact,
we have a Z280 lying in some dusty corner, but just never found the time
to change our system for it. If you start building a new system, by all
means use a Z280! (To me, it has always seemed a waste to use the Z280
only for a CP/M Plus system, which several people seem to be doing
currently. It can do so much more!)
Summarizing, I would say that almost *anything* is possible. It only
depends on how much effort you want to spend on it. There are no
inherent limits in the Z80 processor that would limit you.
--
Luc Rooijakkers Internet: lwj@cs.kun.nl
Faculty of Mathematics and Computer Science UUCP: uunet!cs.kun.nl!lwj
University of Nijmegen, the Netherlands tel. +3180652271