

My real-time operating system - eworoshow
http://ericw.ca/blog/posts/my-real-time-os/

======
eworoshow
I wrote a toy operating system for school that I recently(ish) released to the
world. It comes with source code and design documents so I thought it might be
interesting for people to poke around in.

~~~
kragen
Looks like fun! What kind of drivers does it have? And what license?

~~~
eworoshow
It was fun! Well, fun modulo writing and debugging all the code in three
months.

As for drivers, the OS really only interfaces with 8250 UARTs; both the VT100
terminal and the Marklin digital interface for the trains were connected via
RS-232 serial ports. There is also, embedded in the kernel, a micro VGA driver
for displaying debug messages.

I don't exactly have a specific open source license in mind. Right now I
suppose you could say it's public domain. I'd be happy for it to stay that
way, unless somebody would like to convince me otherwise?

~~~
kragen
If you want it to be public domain, you could use the Creative Commons Public
Domain Deed to clarify that. Right now, if I were to download your code,
decide not to use it, write something similar, make a successful commercial
open-source product from it, and then you got hit by a bus and your sister
inherited your copyright, she could sue me on the theory that you didn't
really know what it meant when you said, "I suppose you could say it's public
domain."

It's a little depressing to hear you say it took you three months working
really hard, because it means it would probably take me about the same time.
(I have no reason to think I'm any smarter than you are.) Maybe I should stick
to AVRs for real-time stuff...

~~~
eworoshow
Aha, well I'm an only child! Either way, I added some text saying everything
is licensed under a Creative Commons Attribution 2.5 Canada License; thanks
for the advice.

I'll plead ignorance with your second sentence. AVRs? And why should it
depress you that it took me three months? (Keeping in mind that I was taking
other classes at the time, and that there was a ton of competition for lab
space.)

~~~
kragen
Great! That's awesome! (Although it's true that CC-BY isn't really intended
for software, it's open-source and IIRC GPL-compatible, so it's plenty good
enough for me. The 4-clause BSD license recommended by the other poster is not
GPL-compatible.)

AVRs are these fun little cheap microcontrollers; the Arduinos and
Chalkroaches, among other things, use them. Writing enough code to drive a
couple of on-board UARTs and switch between some real-time processes on an
ATMega AVR would be a thing to do in an evening or a week, not three months.
So three months to do the same thing due to the unnecessary complexities of PC
hardware is kind of depressing! It's a little less depressing if you were only
working on it, like, 8 hours a week or something.

~~~
eworoshow
You're right, targeting the x86 architecture added a lot of complexity without
any tangible benefit. Poring over the subpar Intel documentation consumed an
inordinate amount of time.

That said, it only took a little over a month to build the OS itself, while
the other two months I spent working on the train control program. All the
equipment is notoriously flaky so coping with real-world brokenness was
probably the biggest time sink.

~~~
kragen
Oh, well, a month part-time doesn't sound so bad. And I already have a lot of
the subpar Intel documentation in my head.

------
s3graham
Ah, that video brings back nice memories of bleary-eyed nights in the Real-
Time lab. :)

... That and rage at the crappy, broken, unreliable sensors we had at the
time. Damn hardware always messing with pretty software abstractions.

What was your gratuitous fluff process to "prove" that the OS was mostly real-
time-ish?

~~~
eworoshow
Demonstrating that the OS was real-ish time consisted of showing that (1) it
never dynamically allocates memory, (2) it uses constant-time algorithms. More
practically I did a bunch of timing to show that, under real loads, it
generated responses under certain (arbitrary) thresholds. In conclusion: a
process lacking even the smoke and mirrors of rigor.

~~~
s3graham
Sorry, I didn't mean to imply your measuring process was fluff.

When I did 452 we had to do something on-screen, to demonstrate
responsiveness. I did the "water demo effect" (similar to
[http://www.derschmale.com/demo/pixelbender-
water/PixelBender...](http://www.derschmale.com/demo/pixelbender-
water/PixelBender.html)). It had to animate without hitching under load, which
I guess correlates with your response timing tests (the arbitrary threshold
being 60 or 30 Hz in this case).

Anyhoo, I meant "process" in terms of OS-level process, and "fluff", because
mine was just lame graphical fluff. :)

btw, planning any more co-op terms before you graduate? Drop me a line.

~~~
eworoshow
Ah, I guess the course requirements have changed in the intervening years. We
got somewhat less time to work on the OS "thanks" to renovations in the lab;
none of us had time to get a full, graphical VGA display running.

That said, I think your display better demonstrates real-time-ness than my
somewhat-less-than-rigorous measurements. By the time you account for all the
assumptions I made to get semi-complete numbers, a working demonstration of a
real-time process is far more convincing!

------
tlrobinson
Wow, model trains have gotten fancy!
(<http://www.marklin.com/CentralStation08.pdf>)

The one I had as a kid looked like this:
[http://www.rubylane.com/shops/seniormovingspecialists/item/T...](http://www.rubylane.com/shops/seniormovingspecialists/item/TCTrain17)
(though it was previously my dad's)

~~~
DanielBMarkham
Wow!

The only thing I can think of as a next step is to install micro-webcams in
the engines and have that virtual-world headgear to see the scenery from the
model's viewpoint.

Amazing!

~~~
eru
Startup oppurtunity?

By the way: Why are model railroads still expensive? Shouldn't the Japanese or
Koreans (etc) have invaded the market by now with affordable, high-quality
goods?

~~~
DanielBMarkham
It definitely has all the initial attributes: clear market niche, mature
market with room for innovation, users willing to trade value for money.

You could do some really cool stuff, like a hardware box for train control
that has wi-fi, OLED, and a web server. Combined with some custom equipment,
like the engine/webcam idea or others and it could be a killer app/platform.

On the down-side, you need to be really close to the customers, you need to
know what sells and what doesn't, and you need tight and immediate feedback as
you try new ideas. You also need a way to communicate to lots of them at the
same time -- repeatedly.

I think it's a great startup idea. I'd be concerned about those challenges
though. The best situation would be to launch as part of a partnership with
well-trafficked, locally-run hobby stores. Perhaps with the
cooperation/endorsement of a large hobbiest club and good press from the model
train magazines.

I don't think any of that is cheap or easy, but there's always obstacles.

~~~
eru
Thanks for the analysis.

The webcam idea may make it viral. Perhaps you can even implement controlling
the trains via the net, so that you get a kind of train simulation. Though you
would have to be in touch with customers to see if this is an idea that sells.

~~~
DanielBMarkham
We're thinking along the same lines.

Would I want to surf home from work and play with my train set? Both as a
switchboard operator and as a virtual engineer/passenger? Would I want my
friends to share in this experience with me? Running other trains, or coming
along for the ride? Making movies of the experiences?

Heck yes. I'd even want a link into FaceBook where people could tell what's
going on in my model world in case they wanted to join in.

Model trains are virtual worlds. The more you can make it like a complete
MMORPG with social hooks the more viral it becomes (in my opinion)

~~~
eru
My kid might even put an obstacle on the real model railroad and you'd have to
brake the train via the web to avoid a crash.

