RSX180

This is a system I wrote back in the early 80s, after home-brewing my first 8080-based machine. Before that, my computing experience was mostly limited to programming under the RSX-11M system that ran on PDP-11 machines, and that's the main reason this system ended looking like the DEC OS.

It all started as a simple hobby project, but when I saw that the much simpler and slower 8080 could cope with multitasking rather well, I continued developing it (added device drivers, a simple filesystem, etc.) I lost interest and abandoned the project when I got my first copy of MP/M - an elegant, small multi-tasking multi-user OS that maintained for all practical purposes full compatibility with CP/M, something that I always thought would be difficult, if not impossible, to achieve.

Recently I found an old backup cassette tape with the code I thought I had lost forever, and the system was resurrected. I ported the original 8080 code to the Z180 CPU, fixing many bugs in the process and bringing the functionality of the system even closer to RSX-11M.

Most utilities have been written again from scratch, this time directly in Z80 assembly, since the source either was not present in the cassette tape or could not be recovered. The original filesystem has been enhanced as well (it lacked things like a master index file and file protection mechanism), and made Y2K compliant.

Similarities with DEC's RSX-11M

RSX180 not only gives the look-and-feel of RSX-11M, including an MCR-style Command Line Interpreter and a set of similar utilities such as PIP, HEL, BYE, Indirect Command Processor, RMD, etc. but the OS itself follows closely the philosophy and design principles of RSX-11M:

  • Priority-based multi-tasking micro-kernel with round-robin scheduling of tasks of the same priority.
  • Multi-user.
  • Multi-terminal.
  • QIO mechanism.
  • AST support.
  • Event Flags.
  • Send-Receive task communication mechanism.
  • Kernel functionality extended by privileged tasks.
  • Task Directory for fast task activation.
  • Tasks can be fixed in memory for even faster activation.
  • Device drivers with ACP support.
  • Dynamic allocation of system resources.
  • Task checkpointing (swapping to disk).
  • Fork processes (not to be confused with Unix's fork).
  • Clock queue and time-scheduled task execution.
  • Privileged and non-privileged users.
  • Similar 2-level filesystem structure.
  • Similar device and filename conventions.
  • MCR-like CLI, including catch-all task support.
  • Similar set of basic utilities and MCR commands, with similar syntax.
  • Syntax-compatible Indirect Command Processor.

Differences with RSX-11M

Besides being obviously written in a different machine language, and for a totally different CPU and platform:

  • System calls are different, although they share many similarities. Same for the various system data structures.
  • Reduced set of QIO function codes.
  • Task dispatching: separate ready and waiting lists, where the next task to run is taken from the top of the ready list. RSX-11M has one single list and a "dispatch pointer".
  • No memory protection and reduced memory-management capabilities, due to the limitations of the simple Z180 MMU (but then again, RSX-11M could be generated for PDP-11 systems without MMU and without memory protection).
  • No resident libraries, no resident commons. Again, due to Z180 MMU limitations.
  • No task overlays, although they could be implemented.
  • Different filesystem and different file formats: RSX-11M uses ODS-1, while RSX180 uses a custom format, with exact file sizes and named directories.
  • No RMS.
  • RSX-11M uses octal everywhere (e.g. for device unit and file version numbers), RSX180 uses decimal.
  • RSX-11M uses RAD50 for file names and such, RSX180 uses plain ASCII.
  • No SYSGEN procedure. The P112 hardware does not have a large set of peripherals like the PDP-11 had, thus only very few options need to be changed, if any, before compiling the kernel.
  • And many more...

Booting the system

If your P112 has a 3.5" HD floppy drive then you can copy a ready-made RSX180 disk image to a freshly-formatted floppy disk (on Linux you can use e.g. the dd command.) For the starters, use the image with basic terminal support.

For best performance format the floppy first under CP/M, so the sectors will have the optimum interleave value for the P112 hardware. Otherwise, disk accesses will be very slow.

Place the RSX180 system diskette on the first floppy drive and reboot your P112:

SMC IO chip identified (FDC37C665IR): configuring
ROM-code built: 04 Feb 2006  CPU clock: 16.000MHz
RAM available: 1024kB. From 00000 to FFFFF
        ROM shadowed into 1st 32kB



P112 1024K RSX180 V6.15

>RED DY0:=LB:
>RED DY0:=SY:
>MOU DY0:
>@SY0:[SYSTEM]STARTUP.CMD
>tim
18:18:28 24-Mar-2020
>set /colog=on
>set /colog/nocoterm
>pip [syslog]*.*/pu:5
>upt
Up 0 days, 0 hours, 0 minutes and 16.09 seconds.
>@ <EOF>
>

The instructions in uppercase are automatically generated by the initialization task to redirect the system devices to the boot drive and then to mount the system disk. Then, if there is a STARTUP.CMD command file in the [SYSTEM] directory, it is executed much like RSX-11M does.

Using the system

If you have some basic knowledge of RSX-11M then you'll feel quite at home with RSX180. Care was taken to make the command syntax as similar as possible.

Once the system is up and running, users can login into their accounts using the HEL (or HELLO) command.

The main (console) terminal remains logged into the SYSTEM account after the booting process finishes; in order to login into a different account you'll have to logout first with the BYE command.

Each user is assigned a directory where he/she can keep his/her files; the directory has the same name as the user name. In addition, users can be identified by their User and Group IDs; users with a Group ID lower than 10 are privileged (much like being root in Unix) and have access to system-management commands.

The HELP command displays information about a particular command or utility (e.g. type HELP MCR for help on MCR commands, HELP PIP for help on how to use PIP, etc.) Note that at this point help files are missing for some of the utilities, or the information is not complete.

To log off the system, use the BYE command.

Like RSX-11M, RSX180 has the concept of Task Directory. Tasks can be entered into the directory by a system manager via the INStall command and removed with the REMove command. Among other things, the directory contains pointers to the location of the task image on disk in order to allow for fast activation. Ordinary users can still run non-installed tasks via the RUN command.

As in a real RSX-11M, a number of important system tasks are always active and the system will crash or become unresponsive if any of these tasks are killed. A real RSX-11M will refuse to abort certain critical tasks, but RSX180 will happily let you to do so. Therefore:

  • Do not abort the SYSFCP task, or no file access will be possible. Even when the task remains installed, it will not be requested again by the kernel to do file I/O.
  • Do not abort LDR... (the loader task), or you will not be able to start any new tasks.
  • Do not abort MCR... (the resident portion of the CLI), or the system will no longer accept any further commands.
  • It is recommended to keep the task-termination-notification task TKTN fixed in memory in order to avoid infinite notification loops in case of e.g. disk I/O errors.

Shutting down the system

Normally, the P112 can be safely turned off if RSX180 is idling, active tasks have no open files, and no disk I/O activity has taken place in more than 5..6 seconds (the file buffer flush interval).

But in order to ensure a safe shutdown, using the SHUTUP utility is recommended. This special task sends a warning message to all logged-in user terminals, stops the console logger, forces user logout after a defined time interval, kills any remaining active tasks, disables the checkpoint file, safely dismounts disks and halts the system.

Installing on a hard disk partition

Although RSX-180 can be run from a floppy and still exhibit acceptable performance, running the system from a hard disk partition will give it the benefit of faster disk data transfers and access to a large disk space.

Steps:

  1. Create an empty partition with FDISK. You need to do this under CP/M or UZI180, as there is no RSX180 version of FDISK at this point. The partition type does not matter, as RSX180 will recognize all hard disk partitions (I normally set it to D8, as future versions of the INI utility may enforce this).
  2. Boot RSX180 from floppy.
  3. Use the INI command to initialize the partition. Be sure to specify the correct device name and unit number for the partition you created (e.g DU0: for first partition, DU1: for second, etc.)!
  4. Use the MOU command to mount the just-created filesystem. At this point it will contain a minimum set of system files and only two directories (MASTER and SYSTEM).
  5. Use PIP to copy the contents of the SYSTEM directory of the floppy to the same directory on the hard disk.
  6. If you want the partition to be bootable, you need to copy the system image SYSTEM.SYS from the MASTER directory of the floppy disk to the hard disk (there may be already an empty SYSTEM.SYS file, delete it first). Then use the INI ddn:/WB command to update the boot loader map. Don't forget to set the bootable flag of the partition with FDISK as well, or the P112 ROM will not boot from it.
  7. Use UFD to create any necessary user directories.

To automate the above steps, the distribution floppy image contains a SYSCOPY.CMD command file in the [SYSTEM] directory that can be used to duplicate the floppy system on a selected hard disk partition.

Programming considerations

Since the Z180 lacks user/kernel mode and memory cannot be write-protected on the P112, RSX180 relies on tasks being well-behaved, and that means that tasks:

  • Should not use the di and ei CPU instructions, except perhaps to avoid race conditions with AST processing (better use system services to enable/disable ASTs accordingly), or by privileged tasks when accessing certain kernel data structures.
  • Should not access I/O ports directly. Write a device driver and use QIOs instead.
  • Should not manipulate MMU registers directly.
  • Should not perform memory writes outside the space allocated to them, or they risk overwriting another task. A system directive can be used to find out the top of allocated memory; if necessary, another directive can be used to extend the task address space.
  • Should avoid infinite and/or timing loops. Use the clock/timer services for that.

There are also some other conventions regarding e.g. I/O:

  • Avoid reading one character from the console at a time. Read a full line instead for better performance.
  • Likewise, avoid writing one character at a time. Write a full string instead.
  • CP/M, MS-DOS and similar OSes generally output text lines as this: "string",CR,LF whereas in RSX-11M and RSX180 this is typically done like this: LF,"string",CR. That's mostly due to old FORTRAN conventions. Failure to follow this rule will result in CLI or task prompt overwriting, etc.

Filesystem format

RSX180 uses a custom filesystem format which is described in more detail here. The main characteristics are:

  • Semi-flat (2 levels)
  • Named directories.
  • Hierarchical directory support is theoretically possible (will require modification of the filesystem handler task SYSFCP, utilities like PIP, the file I/O access library FCSLIB, etc.)
  • Version numbering allows multiple versions of the same file.
  • Y2K compliant.
  • Contiguous and non-contiguous files.
  • File access protection bits.
  • Fixed block size of 512 bytes.
  • Cluster sizes of 1 to 16 blocks.
  • Maximum of 2^24 (16M) clusters, with a practical limit of 4Gb per disk or partition.

Device drivers

The following device drivers are currently implemented for the P112:

  • TT: Terminal driver, fully interrupt-driven
  • DY: 3.5-inch 1.44M floppy disk driver, interrupt and DMA-driven
  • DU: GIDE hard disk driver
  • LP: Printer device via the P112 parallel port (not tested)
  • CO: Console pseudo-device driver
  • NL: Null device driver

Basic and Multiplexed terminals

RSX180 can be generated with one of the two variants of the terminal driver:

  • Basic terminal driver supporting two serial lines - TT0: on the main serial port of the P112 and TT1: on the auxiliary port.
  • Extended terminal driver, supporting nine terminals - one on the main serial port of the P112 (TT0:) and eight multiplexed terminals on the auxiliary port (TT1: to TT8:). The extended terminal driver requires a special de-multiplexing software on the remote machine; a Linux application is available that allows up to 8 telnet connections to the RSX180 virtual terminals.

Bugs and limitations

Please note that this still is a work in progress. The kernel is rather complete and stable, the system can be booted and used, but there are many unfinished details, basic utilities are still missing features and bugs are very likely hiding somewhere in the code.

Some of the limitations were already mentioned above. In addition, there are many unimplemented and/or unfinished features:

  • File protection is not fully implemented at this point.
  • No loadable driver support, all drivers are included in the kernel (resident) during system generation.
  • The indirect command interpreter is lacking e.g. begin-end blocks and some other features.
  • PIP is not complete either (e.g. setting of file protection and/or ownership during copy, directory listing by e.g. date ranges, etc.)

Linux tools

Volume handling:

vol180 is an utility that can be used to transfer files between RSX180 volumes and the Linux filesystem. The program works in interactive mode, accepting a number of commands to mount volumes, create user directories, import an export files, etc. At the program prompt, type help to list the available commands.

fsck180 is a tool that checks RSX180 volumes for consistency and repairs errors in a manner similar to Linux's fsck. Be aware that the current version of the utility is not yet able to fix certain filesystem errors like cross-linked files, but such cases are very rare anyway.

Multiplexed terminal support:

The extended terminal driver supports eight multiplexed terminals on the auxiliary port of the P112. On the remote machine, decoding of the data packets is done with the vtcp utility, which makes the individual terminal lines available to the external world via a configurable TCP port. The port supports the telnet protocol, thus a terminal program like putty on Windows or the telnet command on a Linux xterm can be used to connect to the P112.

Command syntax:

vtcp device [-b speed] [-p port] [-t] [-d]

where

  • device is the Unix name of the serial device the auxiliary port of the P112 is connected to, e.g. /dev/ttyS0
  • speed is the serial port baud rate and defaults to 9600 if the option is not specified.
  • port is the TCP port number used to listen for connections, defaults to 8000 if the option is not specified.
  • the -t option enables telnet mode, disabled by default but recommended unless you are using a terminal program that can connect in raw mode.
  • the -d option enables debug mode (forces display of packet contents on the standard output), disabled by default.

For example:

vtcp /dev/ttyS0 -b 19200 -p 4000 -t

Then you can login on the P112 from the same (or another) machine:

$ telnet localhost 4000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

>
>hel
User name:

Note that you have to press Enter at least once to get the default MCR prompt.

The multiplexing protocol is extremely simple, without error detection and connect/disconnect notifications. Nevertheless, it works very reliably provided you don't push the P112 serial speed limits.

Since a single TCP port is used, terminal lines are assigned sequentially to TCP connections: each new user gets the first free line. When no more lines are available, the vtcp application will refuse (close) further incoming connections.

The fact that there is no connection/disconnection notifications means that no automatic logout happens when you close the connection. Thus, never forget to use the BYE command before leaving, or the next user will have full access to your account!

Last modified 24-Mar-2020.