Hacker News new | past | comments | ask | show | jobs | submit login
My real-time operating system (ericw.ca)
44 points by eworoshow on Jan 23, 2009 | hide | past | favorite | 26 comments



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.


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


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?


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...


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.)


Creative Commons Attribution is not the Public Domain, and it's not a good idea to use the CC licenses for source code.

If what you want is for the code to always have your name on it, you should use a 4-clause BSD license (the original one with the advertising clause).


Also, for the record, there is this: http://creativecommons.org/licenses/publicdomain/

It's not really a license, it just lets you certify that you are putting your work in the public domain.


Ah, thanks for clarifying things. Now I have the code licensed under an MIT license. Out of curiosity, what are the implications of changing the license on software you've already released?


As far as I know, there is no problem at all issuing code under a new license provided that everything in the code is yours. The only tricky issue I can think of is that you can't really revoke an earlier license, so if you are moving to a less permissive license you can't stop people from redistributing under the previous license. So if you decided to relicense from something like BSD to GPL, you couldn't stop people from releasing the earlier version under the BSD, but there is nothing keeping you from only hosting and working on the GPL branch.


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.


be a thing to do in an evening or a week, not three months. As someone who wrote an AVR RTOS kernel for a class in Realtime systems I agree, but you're comparing apples to oranges. I can write, and have written, a real-time control system (RTCS) for a set of peripherals in an evening or a few days, but that's not the same thing as an RTOS. The RTCS is a specific case, the RTOS is the general one and as a result it's much more complex because it has a more open-ended specification. My RTOS took me about 4 weeks or so before it was usable.


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.


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.


CS452 for the :P I hear rumours they are moving away from x86 for that course, have you heard anything about it?


Yes, Cowan wants to buy ARM processors. I believe he is planning on soliciting funding from the Mathematics Endowment Fund this term. (disclosure: I'm the MEF Director)


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?


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.


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...). 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.


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!


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... (though it was previously my dad's)


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!


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?


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.


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.


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)


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.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: