Coherent 3.0

I don’t know why I was so dumb as a kid, but I remember thumbing through various magazines, and always seeing this ad:

Coherent Ad

And isn’t that sounding great?  Lex, Yacc, UUCP, and UNIX functionality on a AT compatible machine for $99!  And then you see reviews like this one from PC Mag:

Now even if you want to you can’t wind the clock back to the late 1970s, but Unix lovers can do the next best thing-pick up a copy of Mark William’s Coherent for $99.95.

Included in this time capsule are all of the utilities that you would have received in an AT&T Unix, Version 7, distribution circa 1978. The package includes a protected-mode multi-user multitasking operating system. over 150 utility programs, a C compiler, an assembler, software development tools, text formatting tools, system management tools, telecommunications utilities, and complete documentation in a very hefty, 1,000-page, perfect bound book. Most of the Unix classics-grep, ed, sed, awk, lex, sh, emacs-are there as well. The only favorites that are missing are vi (which is a text editor) and Dave Korn’s new shell.

Whether Coherent’s views on the Unix system match your own is a matter of taste. In the halcyon late 1970s, the Unix system was a relatively simple affair-lean and clean, and understandable to mere mortals. Since then, in an effort to make Unix the universal solution, countless features and versions have been grafted onto it by innumerable programmers, managers, committees, and boards of directors.

The result stands in stark contrast to the stated goals of Unix’s inventors. Coherent remains true to Unix’s roots and eschews local area networking, graphical user interfaces, menus, mice, and many of the other amenities that present-day DOS users and Unix users have come to expect of modem software.

Coherent’s installation is painless, but only after the agony of freeing up a 7MB or larger partition on an ordinary MFM or RLL disk, on a classic AT architecture machine. Since they are products of the modem era, ESDI and SCSI disks, as well as IBM’s Micro Channel architecture are not supported. Graphic display adapters are tolerated (used in text mode); mice are not supported. Coherent worked flawlessly, though, on my geriatric AT clone.

Coherent has a dual boot facility, so that you can choose to boot either DOS or Coherent during your startup procedures, but unfortunately you can’t run
DOS software from within the Coherent environment.

Mark Williams’president Robert Schwartz explained that the intended audience for Coherent are people who want to learn about or try the Unix system, without the hefty price tag and steep learning curve of the latest Unix versions. Part of Coherent’s advantage in both simplicity and price stems from its origins as a privately developed “clone” product-therefore no AT&T requirements need be met and no per-copy royalty is paid to AT&T. This gives Mark Williams the freedom to set prices as well as compatibility targets.

But learning Unix from Coherent would be a bumpy road. You could certainly master traditional system administration, learn the utilities. And experiment with Unix software development. But you couldn’t learn about networking or the increasingly important X Windows system. Nor could you realistically use Coherent to automate a small business.

Schwartz promises that future versions of Coherent will support 32-bit operation on the 386, and will likely support tighter integration with DOS, some form of window manager. And local area networking. When that occurs, Coherent will be much more like modem Unix systems and, like modem Unix systems, it will have strayed far from its roots.

List Price: Coherent Version 3.0, $99.95.
Requires: A free 7MB or larger hard disk partition, 640K RAM, highly disk drive, MFM or RLL controller.

Mark Williams Co., 601 N.
Skokie Hwy., Lake Bluff. IL
(Kaare Christian)

And then it seemed to my teenage eyes something pretty underwhelming.  So I dove into OS/2, and ignored the idea of having a UNIX like system.  I was still happy to finally move onto a 16-bit machine, and the thought of running stuff from the 1970’s wasn’t that appealing. Such missed opportunities.  But in the last few years, Coherent has been placed under a 3-clause BSD license.

Over at unix4fun, they did unearth some version 3.0 disks!  And yes, it’ll install on PCem/86Box using a 286/386/486 machine.  One issue I had was I first tried to install onto a massive 40Mb disk, and it never would reboot after the install correctly.  However it works great with a 32Mb or smaller disk.  As you can see from Kaare’s review it’ll fit into 7MB of disk space!  At least having to either re-partition or worry about dual booting is a thing of the past.  The disk images are 5.25 disk images, so re-configure your VM appropriately.

Coherent on PCem

As the advertisement says, the installation is a mere four diskettes!  And yes, it really does have a C compiler.  You will need a serial number for Coherent 3.0, which took a while to find, but Peter had one, and has been poking me for the last week+ to finally write this up.  Oh the number is 130500000.  305/Miami connection? Unlikely, but who knows.  Don’t forget to download the hefty manual, Coherent_Revision_8_1992, which is for a later version, but still suitable.

And yes, it feels just like Unix v7.  The kernel is tiny, 77kb!  It’s really cool for 16-bit era stuff, and really interesting to knock around.  I know there is a few more people out there that want fun things for their 286, and Coherent will certainly scratch that itch.

Additionally on the site are the 3.1 and 3.2 updates to give you thinks like Elvis so it doesn’t feel anywhere near as primitive.  Installing updates and 3rd party packages is covered on page 736 of the manual, or in short you need to know the magical ‘disk set name’ for everything you want to install.  I suppose back then it had stuff like this printed on them.

coh300-ddk.img Drv_110
coh300-rdb.img rdb
coh31update-1.img CohUpd310
coh320update-1.img
coh320update-2.img CohUpd320
coh320-ddk.img

While a ‘dump’ of the source code has been out there, I haven’t really gone through it, so I thought now would be as good as any to take a look at the kernel.  The layout is very similar to v6, so I based this on the file ‘sys1.c’ which appears quite a few times in the trees.  Using a MD5 checksum against the files there appears to be no less than 17 duplicated tress or 7 unique kernels, spread over three years.

cc3b2bef09be7d60d52a01ca908972f7 Jul,24,1991 gtz/relic/d/kernel/USRSRC/coh/sys1.c
cc3b2bef09be7d60d52a01ca908972f7 Jul,24,1991 romana/relic/d/kernel/USRSRC/coh/sys1.c

41797301f9d5771dd10161954df82a5d Jan,13,1992 gtz/relic/d/286_KERNEL/USRSRC/coh/sys1.c
41797301f9d5771dd10161954df82a5d Jan,13,1992 romana/relic/d/286_KERNEL/USRSRC/coh/sys1.c
6b888a45afb3476c5e482fa54fb4dd86 Jul,17,1992 gtz/relic/b/kernel/coh.286/sys1.c
6b888a45afb3476c5e482fa54fb4dd86 Jul,17,1992 romana/relic/b/kernel/coh.286/sys1.c
6b888a45afb3476c5e482fa54fb4dd86 Aug,11,1992 gtz/relic/d/PS2_KERNEL/coh.286/sys1.c
6b888a45afb3476c5e482fa54fb4dd86 Aug,11,1992 romana/relic/d/PS2_KERNEL/coh.286/sys1.c
b90f2659fdecfbfa576d39bc8e54ffa0 Aug,11,1992 romana/relic/d/PS2_KERNEL/coh.386/sys1.c
b90f2659fdecfbfa576d39bc8e54ffa0 Aug,11,1992 gtz/relic/d/PS2_KERNEL/coh.386/sys1.c

6503663ebb9a852007a46d66cd43ac1a Jun,14,1993 gtz/relic/b/kernel/coh.386/sys1.c
6503663ebb9a852007a46d66cd43ac1a Jun,14,1993 romana/relic/b/kernel/coh.386/sys1.c
35bc7569ab99ab340d2ca8bf66a47c46 Aug,9,1993 romana/relic/b/STREAMS/coh.386/sys1.c
35bc7569ab99ab340d2ca8bf66a47c46 Aug,9,1993 gtz/relic/b/STREAMS/coh.386/sys1.c
436f245293c88ceaecd99840c37dcbb4 Nov,15,1993 gtz/hal/r10/coh.386/sys1.c
436f245293c88ceaecd99840c37dcbb4 Nov,15,1993 gtz/src/sys.r12/coh.386/sys1.c
436f245293c88ceaecd99840c37dcbb4 Nov,15,1993 gtz/src/sys.r12/coh.386/r12/sys1.c

Phew!  Naturally the tree structure drifted, but I went ahead and just did a blind import into my CVS server to take a look. And there really does appear in the 1991 versions to be the remnants of either 2.3.37, 3.2.1.  It’s hard to say.

Coherent vs IDE controllers…

Since there has been some buzz on Coherent, I thought I’d see what the state of emulation is in 2015.. .While Qemu 1.2.0 can install Coherent, the hard disk access is incredibly slow.  Luckily for me, I was basically stuck on hold, and bouncing between tasks so the four hour long install didn’t seem so bad.

So for anyone who wants a pre-installed disk image, here you go!  It’s installed on a 500MB disk image, with the geometry CHS=1015/16/63

Unimplemented transfer 0x31 on Bochs.

Unimplemented transfer 0x31 on Bochs.

The first thing I tried to do was to get it to run on Bochs.  This was somewhat as easy as mounting the disk, and setting the hard disk to bootable in the Bochs setup program. Coherent boots up, and then starts to print errors that it’s unable to write to the disk.

write cmd 0x31 (WRITE SECTORS NO RETRY) not supported

So, the CPU seems to work, but without the ability to write to the disk, it isn’t too useful.

Next I tried PCem, and I got this error from both the 386DX and 486DX:

PCem in

PCem Spurious GP Fault on iret to Ring 3.

Which is a shame, as I thought that PCem would probably handle any sensitive timing issues the best.

Next up, I tried VMware Player.

Failure on VMware Player

Failure on VMware Player

Which had issues with the hard disk.

Next I thought MESS may actually be able to run it.

First step is the convert the flat disk image into a CHD:

D:\mess>chdman createhd -i \qemu\bochs-flat.img -o coherent.chd -chs 1015,16,63 -c none -f
chdman – MAME Compressed Hunks of Data (CHD) manager 0.153 (Apr 7 2014)
Output CHD: coherent.chd
Input file: \qemu\bochs-flat.img
Compression: none
Cylinders: 1015
Heads: 16
Sectors: 63
Bytes/sector: 512
Sectors/hunk: 8
Logical size: 523,837,440
Compression complete … final ratio = 14.6%

And then to run MESS:

mess64 -window at386 -ramsize 8388608 -harddisk1 coherent.chd

Stalling on MESS

Stalling on MESS

It boots, it seemingly doesn’t crash, but it just hangs there.  I assume it’s also plagued by the insanely slow hard disk access that Qemu struggles with.

And finally I thought I’d give Virtual PC 2004 a shot. I converted my raw disk image to a VHD, and fired it up (nested on Windows XP on VMware Player)

qemu-img.exe convert -f raw -O vpc bochs-flat.img coherent.vhd

And shockingly it slams the CPU and acts like it wanted to boot:

Coherent on Virtual PC

Coherent on Virtual PC

I don’t know if this counts for close.  But this is the current state of emulation.

So it’s great that there is source, although it looks like it’s several internal branches of the PC branch (the source only mentions the PDP11, 68000 and Z8001 ports in libc), but there is a bunch of RCS files.  Its more so a matter of going through all of that to parse out project tree’s and see which ones are newer.  Not all parts have RCS files though, the userland is just a straight source dump.

I’d suspect the only viable way to get this running on modern emulation is to really get it either cross compiling, which means building it’s toolchain, and trying to build a new kernel or finding old enough hardware to build on.  I can’t even begin to imagine trying to use a compiler on a disk that functions at 1kb/sec.

*** UPDATE ***

Well I thought I’d go ahead and try a newer version of Qemu for Windows, namely the 20141210 build, and here we go!

Success! Qemu 2.2.50 running Coherent

Success! Qemu 2.2.50 running Coherent

It takes about a minute to boot up, as it’ll run an aggressive (and silent) fsck.  I can only assume it scans the entire volume as I don’t see why it takes so long.  I also didn’t try to do anything special, just a guess on how to ‘tweak’ Qemu to be more friendly…

qemu-system-i386w.exe -cpu 486 -m 8 -hda bochs-flat.img

Although I don’t know if you need to reduce the CPU or limit the RAM (remember Coherent can’t swap!).

I need to test some more, as I managed to corrupt the disk editing some files, but I think you need the fsck @ boottime, and need to cleanly shutdown with a:

shutdown halt 0

Maybe now is a good time to read that manual.

Coherent sources released under a 3-clause BSD license

coherent

Print ad for Coherent

For those of you who’ve been living under a rock, or just not that familiar with what Coherent is, it’s a clean room re-implementation of version 7 Unix. What is unique about Coherent is that AT&T sent a team, which included Dennis Ritchie to evaluate the source to make sure that they hadn’t stolen Unix, and they concluded:

“that looking at various corners I couldn’t find anything that was copied.”

So Coherent was free to continue to sell their discount Unix like OS for the bargain price of $99 USD. I had plans on buying a copy as the older versions even supported the 8086, and 80286 however by the time I finally got enough RAM and disk space to make the purchase worth while, Linux was freely available. I believe that Coherent was the first OS to be killed by the Linux juggernaut, followed by SCO Xenix.

So it’s a little late to the party, open sourcing may have helped back in the early 1990’s although it’d seem like an utterly crazy move at the time.
Better late than never, this includes source dumps, and some RCS data, along with random tgz’s and a binary distribution of version 4. Without any doubt this will either help emulators better emulate the machine state Coherent expects, or perhaps fixing Coherent to run on more modern machines.

Coherent was also famous for it’s large, and well documented manual. Luckily the sources to the manual are also available.

So without further ado, here is the pages with the sources to coherent.

On final note of interest is that the Mark Williams Company was founded by Robert Swartz, who’s son Aaron was quite influential until the time of his death.