views:

1108

answers:

9

It seems to me that the most common overly ambitious project that programmers (esp. Comp. Sci. grads) try to tackle is building your own operating system. (Trying to create your own programming language + compiler is probably even more common but not nearly as ambitious.)

For those (like myself) foolish enough to try: aside from the sheer size, what are the biggest *gotcha*s or unexpected roadblocks you've encountered in trying to create your own OS from the ground up?

Edit: A great OS question: http://stackoverflow.com/questions/43180/how-to-get-started-in-operating-system-development/

+4  A: 

I was expecting to do it all in C. I wasn't prepared for the amount of assembly required.

By the way, there are good resources links in these posts too:
http://stackoverflow.com/questions/130065/os-development
http://stackoverflow.com/questions/43180/how-to-get-started-in-operating-system-development

Robert
The fraction of assembly required in the beginning is much bigger in the beginning than later on. Look at Linux for example. A very small part of the Linux Kernel is Assembly. Most of it is C code.
Joachim Sauer
+7  A: 

Being able to speak from actual experience (AROS, the biggest obstacles are:

  • Hen and egg (no os <-> no apps <-> no users <-> can't attract developers)
  • Why even try to compete against Windows? Apple doesn't succeed and they have lots of money and Linux doesn't succeed despite having an enormous and enthusiastic community.
  • Big companies aren't interested at all to bring their apps to your OS (Adobe Acrobat Reader, MS Office, Macromedia Flash, Java from Sun). Without these, and no good OSS alternatives, you can't attract users.
  • It takes very long. In my case, it's been roughly 15 years to get a 1.0 (and we're not 100% there, yet).
  • Compatibility. In order to get any users, you must be compatible to something that exists (so people can continue to use their data, etc). If you're compatible, why change to your OS?

So if you plan to write your own OS, you should consider this:

  • It will take a long time
  • For the longest time, you will be alone. I was lucky because I had this enormously fanatic and dedicated Amiga community which just wouldn't let up.
  • You must find a niche where you can offer a service which no other OS can offer.
  • People who can do this often get better job offers because the perception is "writing OSs is hard" :)
  • You will be a member of a very small, elite group of programmers that can say "I wrote my own OS and it can do more than print 'Hello world!'"
Aaron Digulla
"Apple doesn't succeed"? They make billions of dollars a year. That sounds pretty successful to me.
Bryan Oakley
They just got 10% market share (http://www.tuaw.com/2009/01/02/apple-market-share-tops-10-windows-share-lowest-since-tracking/). That is a lot of money but they surely don't take over. So yes, in their niche, they are successful. Overall, they just can't bother the Windows dinosaur. We'll have to wait until it collapses under its own weight ;)
Aaron Digulla
Any specific technical challenges besides mere size?
mudge
@mudge: Writing drivers for the OS is hard: It's hard to get the specs, you need to buy the hardware to test the driver, writing drivers is notoriously hard (for example debugging interrupts) and you need quite a few of them.
Aaron Digulla
+1  A: 

Writing an OS encounters the same problems as other large software projects.

It lacks clearly defined goals, and has timeline / estimation problems due to lack of experience.

Also it would be useful for the programmer first to create a 'hello world' type operating system, so that he/she learns the concepts behind OS development, and then can focus on developing an OS (not learning OS concepts).

eric
+1  A: 

I think nowadays a lot of people who are otherwise good programmers don't know how little they know about how computers work. You'll need a serious grip on the fundamentals to get a machine to boot your OS from a disk, and that type of knowledge is spread pretty thinly nowadays. You won't find a shelf of books about it nowadays, either.

Interestingly, I asked a question on SO a few weeks ago which involved the type of knowledge which was the bread-and-butter of serious PC programming 10-15 years ago, and one commenter said they considered it to be a hardware question.

I'm not knocking them at all, but I thought it was an interesting reflection on how skills have changed.

Will Dean
+2  A: 

The biggest Roadblock? I think it is when you find out how much gaps there are in the specifications and how many bugs there are in the various implementation.

Seriously, even if you would have all the Specs for all the components (i.e. USB, DMA, IRQ, your CPU...) you will find that a) some things are not specified (i.e. what happens if you send a certain sequence to your USB Device) and b) some things are just bugged and you need to work around them (i.e. the dozens of Bugs in the CPU that are detailed in the CPU Errata that both Intel and AMD publish)

I don't know how many workarounds for bugs there in a modern operating system, but since Linux and *BSD is open source, their drivers tell you much, i.e. this one. And expect to get some seriously negative side-effects like this one.

So yeah, If you try to write an OS, be prepared to curse a lot at hardware manufacturers and start to lose your faith in the quality of modern PCs :-)

Michael Stum
"be prepared to ... start to lose your faith in the quality of modern PCs" No doubt! This reminds me of something I read once to the effect of: if you don't want to see a hack, don't dig through the code. Ie: once you know the deeper internals, you'll see how shoddily it's all put together.
Dinah
+1  A: 

Is it possible to write an OS in managed code? or does the framework for the managed code presuppose that you're already running an OS?

Gabriel
No, and yes. Do you know what an OS, the framework and managed code are?
hmcclungiii
Apparently not well enough. I thought [1] managed code needs to run within the framework/runtime that's doing the managing [2] this framework runs in the OS. However, it doesn't seem illogical to write an OS in managed code... I'm just not sure where the framework would run.
Gabriel
Yes, it is, to a certain extent. Look at Microsoft's Singularity project.
zvrba
+2  A: 

Been there, done that. The biggest obstacle, for me at least, was device drivers. Coding the OS core is the "fun part", however it is useless without being able to do I/O (disk, keyboard, video, network, at least). Today, if I again had the time and will to engage into such project, I'd probably target Xen VM instead of the raw hardware -- if for nothing else, then because it hides many ugly idiosyncrasies of x86 as well as hardware. Xen presents a nice uniform, hardware-independent view of I/O devices, and still gives you enough freedom to play with the "interesting" OS parts (mm, process management, synchronization, interrupts, etc).

zvrba
+2  A: 

I think by far the single biggest roadblock is users - until you've built the majority of a working system, you're highly unlikely to have any users. Without users, you don't have feature requests, bug reports, and consequently there's limited motivation. However, even if you do build a working OS, there's no guarantee you'll get a user base unless you can find a hook that draws people in - what sets your OS apart enough for people to be willing to try beta versions, hang in there when there's hardly any working applications ported to it, etc.

You might be interested in checking out SkyOS - it was developed largely by a single developer (now a small development team). The Wikipedia article has a good summary as well. I think it's a good example of how such a daunting task can be undertaken and turn out pretty well. They've done some interesting things with SkyOS, and it's especially cool to see that come in large part from the efforts of a single person in their spare time.

Jay
A: 

I have read a lot about this and I'm still determined to undertake the work of coding my own OS from the bottom and up. REALLY from the bottom and up. I have (as a private project) studied CPU architecture and its development through the last 20 years or so and its respective assembly versions. Mainly x86 but I will also embrace x64. I am currently looking into Fortran and planning to go C later for further abstraction. I have no interests in earning money on my result and thus rule out a good latter half the roadblocks others face. But then again I compensate by setting huge requirements for my OS.

My OS's main goals are: Educating me, successfully self-modifying / self-educating / self-developing itself and a highest level possible efficiency in that order. The unique thing about it will be its ability to adapt to its host computer by building itself from the ground up dependent on the architecture to ensure the highest level of efficiency. Maybe even a single setup for multiple bit-depths. Next task will then be to do extensive testing of the hardware and modify and calibrate the software dependently. I have some more ideas and features too. I AM hard on myself and I like it!

Deagels
That sounds incredible. When you get your project up and running, can you include the link here too? I'd love to see it. Bonus points if it's open source! I'm not sure why Fortran but to each their own. I started prototyping in a high level language but eventually I'd like to move it to asm and c when complete. We had our first child yesterday though so who knows when I'll get back around to working on it. Happy birthday, Rosie!
Dinah
@Deagels: -1: I don't see how this addresses the question.
John Saunders
@Saunders: You're right. It doesn't.
Deagels