From: Darren Senn (sinster@scintilla.capitola.ca.us)
Date: 05/05/92


From: sinster@scintilla.capitola.ca.us (Darren Senn)
Subject: Re: Writing an OS - questions !!
Date: 5 May 1992 18:29:42 GMT

I started an OS called Syrinx in Summer of 1990. It started off being
286 specific (that was what I had), and is now 486 specifc (thank god
for upgrades)! Feeling an overwhelming desire to continue this thread,
here's my 2 cents.

Syrinx was largely inspired by BSD 4.3 and some little hardware experiments
that I did in my Computer Engineering studies.

I started off from scratch, by writing some utilities under Borland C that
allowed me to format a partition with the Syrinx filesystem, and then copy
files to the filesystem, etc.

Once I did that, I pulled up TASM, and started with my bootsector. I wrote
a little bootsector that could multi-boot between DOS and Syrinx. If you
hit return, it would boot Syrinx, but if you typed "DOS", it would go to
the first primary DOS partition and boot that. In order to boot Syrinx,
I loaded a file called "/init" and executed it.

The first version of the boot sector took about a month to write and debug,
(I HATE DEBUGGING BOOT CODE!) and had the location of /init hardwired into
it. The second version actually searched the filesystem for /init by looking
through directories and the inodes, and took another two months.

Linus mentioned his "die loops". I did something very similar to that, though
my die loops started off by creating an exploding window in the middle of the
screen (ok, so I was bored :) ), and putting the values of all the registers
into that window, then it went into a pretty solid loop:
        @@die: sti ; Disable interrupts
                hlt ; Halt the computer
                jmp @@die ; If I get out of the halt, repeat!
So this thing pretty solidly stopped the microprocessor, and I didn't have
any problems with reboots clearing the screen. Very helpful.

I had to deal with the debug/compile/write/reboot/... loop that Jawaid
Bazyar mentioned. It was slow, but it worked...

There were two big things that slowed me down:
        a) My filesystem was fully formed from the start, and
        b) I switched to protected mode through the BIOS.

I didn't (at that time) know how protected-mode friendly BIOS was, so I
went ahead and used the BIOS function call to switch into protected mode.
That gave me the bonus of getting a descriptor for the BIOS data segment
in my GDT for free. Very helpful. Unfortunately, I really had to go
through loops to keep the BIOS from using my hardware interrupts. Very
ugly.

I never did get as far as Linux has come, so when I found Linux last month,
I jumped in with both feet. Some of my Syrinx stuff is better than Linux's,
but most of Linux is far more advanced than Syrinx ever got.

In general, I think Linus' tactic of getting a bare system up first is a
better bet than trying to make everything fully-formed as you go. I
never did get a C compiler, but I did write an assembler that worked under
Syrinx (I called it Sinas).

One thing that helped my Syrinx development was DOS EXE compatibility. I
checked the header of any files that you tried to execute, and if it was
a DOS EXE header, then I ran it in V86 mode. I could get a number of things
to run, but anything that tried to switch to protected mode would die in
a rather horrible way, so there were a lot of things I couldn't use. I
also didn't support EMS or XMS or DPMI, so those programs were all out.
Basically, what it came down to was that I couldn't run any commercial
programs. :(

Syrinx has now been shoved way back on the burner, however, and I've
gone whole-hog into Linux.

One of the first things I did when I got Linux was to look at the kernel
code (the equivalent to my /init). I was rather surprised to see that
Linus switched to protected mode all on his own, without going through
the BIOS. I also like his little comment in the sources:
        ! This is how real programmers do it
or something to that effect. :)