Wednesday, February 8, 2012

My life with Coherent, part 1

In the early 1990ies my company switched from an S/36 system to a Unix system. No one had any knowledge of that "alien" platform, so I became the expert to be. It was not entirely voluntary: I either made it work or I was fired.

Needless to say I spend lots of time behind the terminal, but it just wasn't enough. Working behind a $100,000 machine on a root account while barely knowing what you were doing was kind of intimidating. I was simply too reluctant to perform the necessary experiments.

In order to get more time and a less intimidating environment I started looking for alternatives, but I quickly found out there were few options. There were some MS-DOS based products that allowed me to write shell scripts, but that just wasn't the real deal. Xenix and SCO were too expensive. And then I found out about Coherent.

Coherent is a full fledged Unix that runs on a simple 386 with a few megabytes of memory - incredible, but true. The kernel is just a few hundred KB, so it boots in an instant. It lived happy together with MS-DOS in its own 40 MB partition. But the best thing was its price: only $100. Needless to say I spend a lot of hours with that little beast, porting my C programs and UUCPing with that "monster" machine back at work.

But every machine comes to a grinding halt at some moment in time. Getting a new PC wasn't a problem, but when I tried to reinstall Coherent I found that it didn't support my new IDE drive. Too bad, but since I had become a proficient Unix system admin I really didn't need it anymore.

Still, with every new release of QEMU or VMware I tried to reinstall it - with little result. That is, until QEMU 0.14 was released. After the arduous task of installing Coherent it bombed out just before the final reboot. But the Dutch don't throw away things that easily. I didn't delete the image, instead I simply waited for the next iteration of QEMU.

When I started it, it seemed it hang right away, but the QEMU monitor told another story. It was still alive. It was reading the disk, but very, very slowly.

Hours later the login prompt appeared and I logged in. The whole thing worked, but it was very sluggish. After having worked with it for a little while it became a bit more responsive. It didn't take me too long to figure out it was the IDE emulation that was slowing it down, reading about 1K a second. But once a file was in cache there were hardly any performance issues.

However, when starting up Coherent performed an 'fsck', which made booting a bit tiresome - I assure you that reading 7 megs at 1 KB/s is no fun. The easiest thing was to remove the 'fsck' check, which was easy enough. A quick edit of 'brc' was sufficient. Now I could login after Coherent had read only 150 KB, which was a significant improvement.

But I still wasn't happy. Every time I rebooted I had an empty cache. There had to be another way. Yes, there was, but for that I had to turn to QEMU. QEMU allows you to make a snapshot of the whole virtual machine - memory, CPU, the whole shebang. That not only allowed me to "boot" instantly, but also with the disk cache intact. Ok, now we're talking!



Since the standard Coherent C compiler only supports K&R C, almost all my C programs have a "-DARCHAIC" switch, which enables K&R prototypes. Even after 15 years I still maintain them, so porting my 4tH compiler shouldn't be very difficult. It wasn't. In these 15 years after more than doubling the code base I had only made about 10 syntax errors, which were quickly fixed.

But still there was a problem. Sure, I could use a raw floppy image to exchange files between the host and the VM, but since you can't make a snaphot of a raw floppy I had to reboot the VM after each and every transfer, which kind of defeated the sense of making snapshots.

The solution was to startup the VM with a QCOW2 floppy, which served no other purpose than to define a floppy device in the VM. You can not easily mount a QCOW2 image and so it is consequently not very well suited for file transfer.

Once the VM is up and running you can exchange this virtual floppy for a raw version by switching to the QEMU monitor and issuing:
change floppy0 fat16.img
When you want to take a snapshot you simply return to the dummy floppy by issuing:
change floppy0 dummy.dsk
And subsequently save the snapshot by issuing:
savevm test0
After that I was ready to rock 'n roll. It took me about an hour or so to port my compiler and transfer the executables back to the host. Furthermore, I installed another more modern kernel, applied some Y2K patches and customized my Coherent 4.2 installation.

In the next part of this series I will describe this in more detail and - even better - give you the opportunity to try it for yourself. All perfectly legal, that is..!

3 comments:

Paolo said...

Thank you so much. After almost twenty years I have "Coherent" back.
The only drawback I have is my keyboard. I'm not able to change the layout to german. Could you please help me?

The Beez' said...

You should be able to switch using:
/conf/kbd/german

If you switch from one of the non-loadable keyboards (vtkb/kb) to one
of the loadable ones (vtnkb, nkb), you must add the keyboard table of
your choice to /etc/drvld.all

Edit /etc/drvld.all
Add a line to load your choice of tables:
/conf/kbd/us for US
/conf/kbd/french for French
etc.

NOTE: only add *1* line; I just gave the above as an example.

If you decide to switch back to non-loadable, you can leave the line
there. It won't hurt anything.

But remember, I can't and haven't tested this so:

Angabe ohne Gewaehr!!

Paolo said...

Thank you for your immediate reply. I added /etc/drvld.all with /conf/kbd/german. During boot sequence a message appeared with "Loaded Virtual German Keyboard V1.6". But the layout is still american.

In my old Coherent (1991 and later) I had the correct layout working.

Do you have any idea?