
Xinu – A small, elegant operating system - rspivak
https://xinu.cs.purdue.edu/
======
ww520
I browsed the source code a bit. Some interesting finds:

* The code is pretty simple and clean, clearly for educational purpose.

* There's no memory protection. All processes share the same memory space, along with the kernel.

* No virtual memory, nor page table.

* No notion of ring protection. The kernel and the processes run in the same ring.

* Max number of processes is 8. The process table is a fixed size array, of 8 entries.

* Context switch can be preemptive, driven by the clock interrupt.

* Process scheduling is round-robin, first in first run.

* Process priority is supported. Each priority has its own ready queue. All processes of the highest priority are run first in round-robin fashion, before running the next priority level.

* "Program" is just a function. All "programs" in the system have their starting functions hardcoded in the shell's cmdtab[], like cat, ping, etc. Executing ping is just creating a process with the address of the ping function.

* Loading a program from disk to run doesn't seem to be supported.

* The local file system is based on RAM block device. Accessing data on actual disk doesn't seem to be supported.

~~~
pmorici
Adding a memory paging system to Xinu is one of the projects for the Graduate
level OS course based on this book.

~~~
bogomipz
Might you or anyone else have a link to a graduate level course that covers
adding these features to Xinu?

~~~
pmorici
It was Purdue's CS503 course when I took it a number of years ago. I don't
think there are any materials to be found online though. As I recall the
professor outlined how x86 paging worked in one of the lectures and then we
were given a link to the Intel manuals and told good luck. To keep things
simple there were no disks in the system so the memory was paged over the
network and they had a special lab setup to support the whole thing.

There is also an Operating systems course at Marquette University based around
Xinu. That one is for undergrads though and based on a version targeted for an
embedded MIPS processor so I don't think it covered paging but I never took
that one so I'm not sure.

------
cabaalis
Was curious about one thing. On the Xinu website, under "Xinu in industry" in
the 2000s, it says that the pinball game for Star Wars: The Phantom Menance
uses Xinu. So I looked up that pinball game.

On the wikipedia page for the game [1], it says that it uses Pinball 2000
hardware. And on the wikipedia page for Pinball 2000 [2], it uses Xina (Xina
is not Apple) and not Xinu. Is there another variant of the OS?

[1]
[https://en.wikipedia.org/wiki/Star_Wars_Episode_I_(pinball)](https://en.wikipedia.org/wiki/Star_Wars_Episode_I_\(pinball\))

[2]
[https://en.wikipedia.org/wiki/Pinball_2000](https://en.wikipedia.org/wiki/Pinball_2000)

~~~
koz1000
Pinball 2000 engineer here.

The "Pinball 2000 hardware" setup was an ATX motherboard running a MediaGX CPU
(x86 clone, it lives on as AMD Geode). It also had a custom PCI card for
storage and sound DSP, and a secondary board connected by parallel port for
driving lamps and solenoids.

XINA was an application layer on top of XINU that handled the executive tasks
of running a pinball machine, and also abstracted the various hardware
features. We used Allegro as the graphics SDK.

The name XINA was inspired by XINU, and was an acronym for "XINA Is Not
APPLE". APPLE was the previous pinball programming system, no connection to
the computer company.

~~~
ChickeNES
I'm curious, does the source code for XINA still exist?

~~~
koz1000
It does, but it's owned by whomever owns the Williams IP. I believe these days
it's Scientific Games.

SG isn't making pinball machines but apparently has licensed the code to an
outside group to maybe remake old games or whatever.

------
aarya123
The professor who made Xinu, Douglas Comer, also contributed heavily to TCP.
[https://en.m.wikipedia.org/wiki/Douglas_Comer](https://en.m.wikipedia.org/wiki/Douglas_Comer)

~~~
Nicksil
Non-mobile:
[https://en.wikipedia.org/wiki/Douglas_Comer](https://en.wikipedia.org/wiki/Douglas_Comer)

~~~
ObsoleteNerd
It's weird that Wikipedia redirects mobiles from the non mobile version to the
mobile version, but doesn't redirect the other way around.

~~~
Klover
That’s likely because I’ve seen a lot of people working on Wikipedia either
via code or via content, prefer the mobile version even on desktop. It’s a
pleasant reading experience.

~~~
laumars
That's curious to read because I find the non-mobile version a significantly
more pleasant reading experience. I don't even like the mobile version on my
phone because I constantly get lost in page when I expand sections (maybe
that's just down to my dyslexia?)

~~~
jimbo1qaz
Hiw many years has it been, and Wikipedia Mobile still has the bug where
pressing Back loses your downwards scrolling, since all sections contract
momentarily (moving your page position upwards).

------
jarym
Crap this article jogged my memory - I now remember Xinu from when I was a
teenager!

It’s a fantastic bit of code for anyone interested in how operating systems
are designed and built.

Glad to see it’s still being kept alive!!

~~~
facorreia
Same here. I learned the rudiments of operating systems by studying Xinu in
college. That was pre-Internet, so text books like Xinu's were hugely helpful.

~~~
JdeBP
Milenkovic's book on KMOS was rather underrated and overlooked, I found. It
covered a couple of things that Comer and Tanenbaum did not.

------
j6jr85ehb7
I took classes with Doug Comer in college and I also maintained part of the
Xinu lab while I was at Purdue. Great to see the impact it has had on OS
education outside of Purdue!

~~~
rovr138
Can you talk about the machines in the lab. I’m in WL and have seen in
Greyhouse and in Lawson people battling with XINU enough that I’ve gone over
to see what they’re doing.

I’m curious about the machines used to run the code in, their boot processe,
or anything you can talk about.

~~~
avaidyam
What would you like to know? I did help set up a few things there. There's a
special netboot-like version of Xinu deployed on the backend systems which are
just Beagle/Galileo/whatever's been upgraded, and they deploy whatever Xinu
image you've supplied. Students typically compile locally and submit the xbin
(compiled kernel image) to a backend.

------
rgovostes
The name seems to have the same derivation as the name of the XNU kernel
underlying Apple's operating systems:

> XNU is an abbreviation of X is Not Unix or XNU is Not Unix.

Wikipedia says the first release of XNU was in '96 (perhaps in NeXTSTEP 4.0?),
though, far later.

~~~
laumars
The recursive acronym " _something_ is not _something_else_ " is a pretty
common naming convention in software. Much like how there are a hundred
different software projects out there called "Yet Another _something_ ". So
I'm not at all surprised we occasionally get collisions. Still makes for a fun
coincidence though.

~~~
vram22
>The recursive acronym "something is not something_else" is a pretty common
naming convention in software

Right. Goes back far, too:

[https://en.wikipedia.org/wiki/Recursive_acronym](https://en.wikipedia.org/wiki/Recursive_acronym)

[https://en.wikipedia.org/wiki/Recursive_acronym#Notable_exam...](https://en.wikipedia.org/wiki/Recursive_acronym#Notable_examples)

I particularly like EINE and ZWEI:

From the linked article:

>the two MIT Lisp Machine editors called EINE ("EINE Is Not Emacs", German for
one) and ZWEI ("ZWEI Was EINE Initially", German for two)

~~~
dfox
There is nowadays also DREI which officially stands for "Drei replaces EINE's
inheritor" or alternatively for lots of other things (see the source for
list), particularly "Drei reimplements Emacs intelligently".

~~~
vram22
Wow, that's cool too. I'm going to create the next one, VIER, for "Vier Is
EINE's Replacement".

[https://translate.google.com/#de/en/Vier](https://translate.google.com/#de/en/Vier)

------
GordonS
Curious to know if anyone has used this for anything serious, and what the
main decision factors were for choosing Xinu?

~~~
koz1000
In 1999 my team at Williams Electronics chose XINU as the O/S for the Pinball
2000 project:

[https://www.youtube.com/watch?v=8rHbsCyde1g](https://www.youtube.com/watch?v=8rHbsCyde1g)

At the time, embedded X86 boards were not really a thing yet so we needed
something simple that could run with a COTS PC motherboard.

The major factor was that the licensing for other operating systems was too
costly or too restrictive. Anything GPL-based was ruled out by our lawyers.
Turning Linux into an RTOS would have forced us to release source code and
that wasn't a fight with Legal that anyone had time for.

XINU turned out to be just what we needed. The process limit wasn't a huge
problem since we were used to running threads on a single process. Adding
networking later turned out to be very easy.

~~~
JdeBP
Did you look at MINIX?

~~~
koz1000
I don't recall. The lead O/S engineer was from Purdue so perhaps he went to
XINU right away out of familiarity.

------
013a
There are a few classes in Purdue's CS undergrad program (at least as recently
as a couple years ago) which leaned a lot on XINU to teach OS fundamentals.
Specifically in the 400-level Operating Systems course, we had one lab toward
the end which reached into Linux for some basic stuff, but otherwise it was
pretty much all XINU; playing with memory allocation, writing a new process
scheduler, stuff like that. Purdue maintains a lab of XINU computers, which I
believe are just Linksys routers of some kind, which students can log in to
from anywhere to complete lab assignments, including a scheduling hypervisor
which ensures that we weren't stepping on each others toes given there were
only ~30 machines.

~~~
avaidyam
Not Linksys routers! They're typically Beaglebone/Galileo cards or something
newer now. They actually run a special netboot-like version of Xinu that
deploys your compiled xbin. (So it's like Xinu running Xinu...) There also was
no such hypervisor, mostly TAs that responded to email complaints and took
systems offline when hogged on accident.

------
avaidyam
Once upon a time, a colleague and myself attempted to rewrite Xinu in Rust to
show Dr. Comer how cool it was. Rust did not work. It was not cool. Dr. Comer
simply smiled a gentle "I told you so," as he had good reasons for sticking to
C.

~~~
steveklabnik
What didn’t work?

~~~
avaidyam
We had tremendous difficulty convincing Dr. Comer that using an
experimental/nightly toolchain to compile an experimental compiler variant to
use experimental libraries in an experimental language was worth it.

It took us quite some time to get everything up in a way that would work on
most Purdue systems and our own personal ones and from there even translating
the limited codebase we were using unsafe code blocks for nearly everything
(and ASM blocks) and some internal code for multicore/ACPI-related
things/Galileo boards we haven't made publicly available yet, AFAIK.

At the end of the day, Xinu was small enough and very concisely written and
maintained for several decades that switching to a language like Rust wasn't
warranted. Similar to sqlite, I suppose. You can email me at
avaidyam@purdue.edu if you'd like to know more details/talk to Dr. Comer about
Xinu things.

~~~
steveklabnik
Ah, okay. That all makes sense! I thought you meant that like, the language
couldn't do it at all. All the stuff you've said is the current state of
things, roughly, for sure. Thanks!

(I'd love to see OS classes use Rust someday, so I'm always trying to keep an
eye out for things...)

~~~
avaidyam
No worries - while I personally enjoyed Rust it was clear that it was
unsustainable for Dr. Comer. He means the best, I assure you. :)

------
vonkale
Google cache:
[http://webcache.googleusercontent.com/search?q=cache:rNJQhgs...](http://webcache.googleusercontent.com/search?q=cache:rNJQhgsfWtoJ:https://xinu.cs.purdue.edu/)

------
usermac
[https://www.bing.com/videos/search?q=xinu&&view=detail&mid=7...](https://www.bing.com/videos/search?q=xinu&&view=detail&mid=7F4FEDD48FE6881FD8807F4FEDD48FE6881FD880&&FORM=VRDGAR)
1st in the video list while investigating. ha ha

------
nkkollaw
Wow, development started in 1980! That's commitment.

~~~
EmilStenstrom
In this particular case, I’d say it’s academic research.

~~~
michaelmcmillan
Not mutually exclusive ;)

