Slashdot Mirror


Building Your Own Operating System?

sonictooth asks: "I have dreams of writing a toy operating system, as I know some people have already done in college. Unfortunately, I don't have that opportunity. I was wondering what books (as there are so many) and methods people [have used], either in college or on their own. Amazon is littered with books from varying authors, Tanenbaum in particular, and there are both positive and negative reviews of his books. Does anyone recommend a simple book to walk you through the early stages, and then explain the more complex theories later on."

102 comments

  1. The Operating System Says... BOOOOT! by Txiasaeia · · Score: 2, Funny
    "I have dreams of writing a toy operating system..."

    input a "Please pull the string."
    if a=1 print "The cow says... MOOO!"
    if a=2 print "The duck says... QUAAACK!"
    if a=3 print "The horse says... NEEEIGH!"
    end if

    --
    Condemnant quod non intellegunt.
    1. Re:The Operating System Says... BOOOOT! by trompete · · Score: 2, Funny

      LMAO. Now, I'm going to take the GPL and sell your operating system for $500 a copy, only to get sued because SCO claims to own the word QUAAACK.

    2. Re:The Operating System Says... BOOOOT! by Anonymous Coward · · Score: 0

      LOL. It's funny because it mentions SCO.

    3. Re:The Operating System Says... BOOOOT! by IPFreely · · Score: 0, Offtopic

      ...
      if a=4 print "Three singing pigs say LA LA AL!"

      --
      There is nothing so silly as other peoples traditions, and nothing so sacred as our own.
    4. Re:The Operating System Says... BOOOOT! by gbr · · Score: 0, Offtopic

      Somebodies reading too much Sndra Boynton (not sure of the spelling there).

    5. Re:The Operating System Says... BOOOOT! by IPFreely · · Score: 0, Offtopic
      Got it memorized, along woth most of the others in the collection. Kids.

      I worked up an alternate wording once that included "Four singing Bugs say YEAH, YEAH, YEAH!". It was mostly pop music based, Beatles and others. Too bad I forgot most of it.

      --
      There is nothing so silly as other peoples traditions, and nothing so sacred as our own.
    6. Re:The Operating System Says... BOOOOT! by Zork+the+Almighty · · Score: 1, Funny

      if a=4 DDOS "www.sco.com"

      Damn, how'd that get in there?

      --

      In Soviet America the banks rob you!
  2. offtopic, but... by ru-486 · · Score: 3, Interesting

    Slashdot needs more items like this! Reminds me of the pre-SCO days...

  3. Amiga RKMs by Mr.+Darl+McBride · · Score: 5, Informative
    Get your hands on the Amiga ROM Kernel Manuals -- both "Libraries and Devices" and "Includes and Autodocs." I&A has the headers for most everything, and the libraries explain the workings pretty well. The Amiga OS was very simple and elegant. Understanding the base (ignore the GUI) will be enlightening.

    Now, these books don't make for a how-to, and you don't get the source for the core OS with them, but if you start by learning the exec interface, then look over the exec headers, you'll quickly develop a thorough understanding of a simple multitasking kernel. From there, you can glom onto the basic device library with the library book, then the headers again, and repeat for the trackdisk library. Jump into console and other libraries as your interest dictates. Don't worry about learning these things in a linear fashion -- going with your interest first is critical for learning something as complex and intricately interconnected as the workings of an OS.

    After seeing how some of these work together, if you've got your head on straight with C, implementing your own equivalent on the PC should be easy. Grab MS-DOS, which leaves protected mode entirely open to you, and build your own system on top of that. No need to start with your own bootstrapper if you can do it with a little DOS code. That way you have BIOS services for the parts you haven't written yet, and can replace bits a little at a time as your interest dictates. Make a simple OS shell first, using mostly wrappers, then drill down until it's time to start making your own device drivers.

    From here, I went on to acquire the IP rights behind UNIX and develop from there, but you can take your own route.

    ~Darl

    1. Re:Amiga RKMs by BigJimSlade · · Score: 1

      Any thoughts about where one might find these titles?

    2. Re:Amiga RKMs by Anonymous Coward · · Score: 0
      You didn't even look before asking, did you.

      Amazon has them used. BB has them used. Half.com has them used. Learn to find answers for yourself or don't even think you'll get anywhere with this.

    3. Re:Amiga RKMs by Anonymous Coward · · Score: 0

      This is HORRIBLE advice ... sheesh.
      Just look at some early linux kernel sources.

    4. Re:Amiga RKMs by Anonymous Coward · · Score: 0

      From here, I went on to acquire the IP rights behind UNIX and develop from there, but you can take your own route.

      ~Darl


      Thanks Darl! Any thoughts on how I could find a great free OS that's already written and claim it as my own?

    5. Re:Amiga RKMs by Anonymous Coward · · Score: 0

      Starting out with Linux sources is sure to frustrate. Even early Linux is an order of magnitude more complex than AmigaOS, and there's no good documentation to go with it.

  4. Here's a list for ya.. by QuantumG · · Score: 5, Informative
    • Learn asm
    • Get used to rebooting your machine or figure out how to get Bochs to compile with the debugger enabled
    • Write a bootloader (I know Grub rocks, but you need the experience)
    • Write a keyboard driver
    • Write a video driver
    • Write a scheduler
    • Write a shell
    • Write a filesystem driver
    • Write a network driver
    • Try to port gcc to your OS
    • Write yet another revolutionary GUI
    • Write everything else

    • Congratulations you've got yet another monolithic kernel based hobby OS that no-one is interested in but you.

      If you want something remotely interesting, try seperating as much of that junk in the kernel as you can into userland. Pentiums now have system calls that are 5 to 10 times faster than they used to be. Think about writing applications that communicate using shared memory pages. If one app writes a page and then instructs the kernel to map that page into another process, the kernel can do that rediculously fast. That's 4k (or more if you're using bigger pages) that has transfered from one process to another in the space of a single system call.

    --
    How we know is more important than what we know.
    1. Re:Here's a list for ya.. by edalytical · · Score: 3, Interesting
      Write a bootloader

      Why? What experience do you gain from this? I only ask because every other tutorial or FAQ, that I have come across, strongly advises you not to do this-- especially as the first step.

      --
      Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
    2. Re:Here's a list for ya.. by Satan's+Librarian · · Score: 4, Interesting
      Actually, depending on what you are looking to get out of the experience and how determined you are, it's a *very* small piece of code that you can learn quite a bit about the PC by writing.

      If you're writing a toy OS to learn the upper level OS concepts, then you're probably better off writing your 'OS' as an app that runs on top of your favorite existing OS. But if you're doing it to learn more about low level programming and the hardware/firmware you're running on, the bootloader is at least a portion you can get done before loosing interest, and it teaches its own lessons.

      Also, if all you want is a baby utility OS/program, you can bootstrap the entire program into memory from a floppy (or bootable CD) bootsector, run it, and be done with it.

      Lessons learned:

      • Assembler language
      • BIOS interrupts
      • BIOS memory architecture
      • Disk structure and I/O
      • How a PC boots
      • How to get lilo back quickly and easily if you install XP onto a partition after linux.
      • Why you should backup your partition table and MBR sector before writing a buggy program to it.
    3. Re:Here's a list for ya.. by addaon · · Score: 2, Interesting

      It checks your tool chain, takes about 4 hours (assuming you know assembly, but not the machine's boot process), it gives you ground from which to start other stuff, it let's you say you're building 'from the ground up', and it gives you confidence by doing something easy.

      --

      I've had this sig for three days.
    4. Re:Here's a list for ya.. by orthogonal · · Score: 0, Flamebait

      Think about writing applications that communicate using shared memory pages. If one app writes a page and then instructs the kernel to map that page into another process, the kernel can do that rediculously fast.

      On modern hardware, in fact, it's so fast that it's often faster than the speed of spelling.

      B modern! Brake the Speling Barior!

    5. Re:Here's a list for ya.. by be-fan · · Score: 1

      Actually, a Pentium 4 has ridiculously slow system calls. Athlons have system calls twice as slow as classic Pentiums, and the P4 is much worse.

      --
      A deep unwavering belief is a sure sign you're missing something...
    6. Re:Here's a list for ya.. by be-fan · · Score: 1

      Nah. If you really want something revolutionary, write your kernel in a safe language. That way, everything can safely be in kernel space, and you don't need system calls at all!

      --
      A deep unwavering belief is a sure sign you're missing something...
    7. Re:Here's a list for ya.. by Pseudonym · · Score: 1

      Huh? SYSENTER/SYSEXIT are lightning fast, assuming you're not switching address spaces.

      You are using SYSENTER/SYSEXIT, right? Plus an INT-based layer for backwards compatability?

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    8. Re:Here's a list for ya.. by be-fan · · Score: 1

      Eh? What do you mean by "lightening fast?"
      Check out The benchmarks.

      It still takes nearly 3x as long as SYSENTER on an Athlon. And an Athlon is slow to begin with. An EV6 was down near 80 clock cycles for system calls! That's about 5x less than the P4.

      --
      A deep unwavering belief is a sure sign you're missing something...
    9. Re:Here's a list for ya.. by pla · · Score: 1

      Why? What experience do you gain from this?

      I would recommend the same thing, for one simple reason...

      If you write a bootloader, you already have written an OS. A bootloader takes a non-running system, and brings it to the level of some basic user-interaction capabilities. Something like Grub even includes a fairly functional shell...

      I suppose it all depends on what you want to learn from the experience. If you care "where did the universe come from", write a bootloader. If you care "How can I get to Mars, with both the Earth and Mars already existing in a pre-made universe", then skip the bootloader step.

  5. One good source by nerd65536 · · Score: 3, Informative

    One good source isn't a book at all: The source code for the Linux kernel. You could also take a look at FreeBSD and any other open source OS. Looking at something that works should give you an idea of what you need to do in your own OS.

    1. Re:One good source by Otter · · Score: 5, Informative
      None of this is really an answer to his question, which is for a text that walks you through the basic concepts -- but one of the annotated Linux kernel texts, similar to the classic Lion's Commentary on Unix is a lot closer to what he wants than telling him to read a tarball.

      But, again, he really just wants to know what the best college-level textbook is.

  6. Google is your friend. by linuxkrn · · Score: 3, Interesting

    I did this years ago. Had a quick boot floppy with a dumb OS that did almost nothing. But it was still cool "just for fun."

    As I suggested, google is your friend.

    Google gives you this first: http://mega-tokyo.com/osfaq2/.

    And this might be good for FS (Fat12) http://www.free2code.net/tutorials/other/20/os1.ph p

    1. Re:Google is your friend. by edalytical · · Score: 1

      The Visopsys project has a page full of OS development links to source code, filesystems info, file formats, hardware references, etc.

      --
      Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
    2. Re:Google is your friend. by mystran · · Score: 1

      Indeed, good starting place is Mega Tokyo forums and specifically the Book recommendations and Quick links threads, which together contain the answer to the question..

      --
      Software should be free as in speech, but if we also get some free beer, all the better.
  7. Easy Answer by Quarters · · Score: 2, Funny
    Just read OSNews The average discussion over there is populated by people with plenty of baseless opinions on OS design and very little actual practical knowledge.

    Yup, I figure if you read everything there and then do the exact opposite you should pretty much be on your way to making a really nice OS.

    1. Re:Easy Answer by duffbeer703 · · Score: 1

      What do you mean?

      The review of the Linux Mandrake installation GUI was a brilliant piece of journalism.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
    2. Re:Easy Answer by E_elven · · Score: 1

      Bug report
      --
      OS: duffbeer 7.03
      Report:
      The system's command interpreter seems to have a glitch. It interprets 'discussion' as meaning 'article', which is completely wrong. I'm currently trying to reproduce the bug by posting on Slashdot. I'll see if I can get it to do it again.

      --
      Marxist evolution is just N generations away!
  8. A College Course You can follow along with by thedanc · · Score: 4, Informative

    I'm taking an Operating Systems course right now. You could follow along with it (or a similar course at any university.) Obviously you'll miss the lectures, but read along in the book and you'll get the same content. (BTW, the book for this class is by Silberschatz; ISBN 0471250600. I only gave Tanenbaum's OS book a quick look over, but so far I like the style of this book more than Tanenbaum's writing that I saw in his Computer Organization book.)

    The course starts you off with a very basic skeleton. From there, we'll add most of the parts of a basic OS in several individual programming projects. The class website is at http://www.cs.umd.edu/class/spring2004/cmsc412/ (won't work in IE) It has everything on it you should need to follow along.

    1. Re:A College Course You can follow along with by kisielk · · Score: 2, Interesting

      "Obviously you'll miss the lectures"

      How come? There's nothing preventing you from walking in to the lecture hall and listening to the prof give his lecture. People do this at my school all the time, it's called auditing. Some of my crazy friends even do the assignments, or help groups with their group work, even if they aren't enrolled in the course!

    2. Re:A College Course You can follow along with by Anonymous Coward · · Score: 0

      "Auditing" is enrolling for a class and then just showing up for the exams (because you already know the material). Listening to a lecture without enrolling is called "trespassing".

    3. Re:A College Course You can follow along with by meme_police · · Score: 1

      I have NEVER heard that definition of auditing. Every school I've been to auditing means attending class without taking tests and doing assignments.

      --

      The meme police, They live inside of my head

  9. You can start by studying DOS by HotNeedleOfInquiry · · Score: 3, Informative
    It's still widely used in embedded systems and there's at least one version (freedos) that's open source. There's lots of FAT disk driver code around and acually getting something to work is not that hard.

    My favorite books are:
    DOS Technical Reference by IBM
    DOS Internals by Chappell
    Dissecting DOS by Podanoffsky (I believe he wrote a DOS as well)

    --
    "Eve of Destruction", it's not just for old hippies anymore...
  10. Highly Recommended by eviltypeguy · · Score: 4, Informative

    I would highly recommend the book:

    The Design and Implementation of the 4.4 BSD Operating System
    by Marshall Kirk McKusick
    Keith Bostic
    Micahel J. Karels
    and John S. Quarterman
    (ISBN 0201549794)

    It's really a great book about a mature operating system and will give you some great technical insights into the hows and whys behind operating systems in my opinion.

    Additionally, most *BSD distributions are a great study because their code tends to be very well organized and they come with *LOTS* of documentation.

    Even reading the FreeBSD developer's handbook here:

    http://www.freebsd.org/doc/en_US.ISO8859-1/books /d evelopers-handbook/

    or the KernelNewbies site here:

    http://www.kernelnewbies.org/

    May be of benefit to you.

    Additionally, I hope you have a high level of reading comprehension. Be prepared to take several trips to your local library or bookstore and spend hours perusing texts to better understand the ins and outs, and quirks of hardware.

    But lastly, even after you do all of the above, the best way to learn is to do! Install a copy of Boch's or if you're a little richer, buy VMWare or VirtualPC (VirtualPC's emulation tends to be better than VMWare's although a bit slower). Get brave and setup and old pc and install all kinds of different OS's on it. That's the best way in my opinion to learn...

  11. Getting started.... by Satan's+Librarian · · Score: 4, Informative
    If you want to learn from a simpler operating system than Linux, Dissecting DOS was an excellent book in its time.

    Assuming you want to go bottom-up in designing the system and you're using a PC, the first things you'll need are a decent grip on x86 assembler and PC architecture. Then, you need to learn the BIOS interrupts/services, since that's about all that'll be available to you.

    I'd think one of the first things you might want to write is a bootstrap routine.The Undocumented PC had a pretty good description of bootstrapping as I recall. Basically, the bootsector of the boot device (first sector on a floppy, the MBR/partition table on hard disk, etc.) gets loaded to 0:7c00 in real mode and gets executed - what you do from there is up to you. Some *really* old video games for PC's came as boot disks and did just that - in a sense, they provided their own simple operating systems.

    After that, you'll get into the more fun stuff - filesystems, memory management, task switching, compilers, linkers and loaders, device drivers, etc. That's where you'll want to be reading your Tanenbaum book, a stack of others, and probably peeking at Linux and other open source operating systems to see how it's really done.

    Good luck!

    1. Re:Getting started.... by xjimhb · · Score: 1

      Bootstraps are not simple . If you are extremely lucky it may go well, but more likely not. I got involved in one once - the worst thing is trying to get debugging info when almost nothing is up and running yet - especially NOT the display. And there was no BIOS either, I was running with an eprom plugged in and replacing the normal BIOS chip - nothing on it except the code I wrote.

      Turned out about the only reliable thing I had was the speaker, and I had to make do with a collection of short beeps, long beeps, low-pitched beeps, high-pitched beeps, single beeps, double beeps ... well, you get the idea.

      It was murder! If you want to start simple, at least work on top of the BIOS, if not on top of a simple OS like DOS.


    2. Re:Getting started.... by Satan's+Librarian · · Score: 1
      Uhm - first off, I was referring to the Operating System bootstrap code on a PC. Typically the software I referred to is on the first sector of a floppy disk or on the MBR/Partition table sector of the hard disk. This is what people refer to as the 'boot sector' or bootstrap code when referring to writing an operating system.

      It's under 512 bytes, which puts a considerable limit on its complexity (although you can use additional sectors if you wish to do more, provided you load them yourself with the first bit of code). You can go a long way towards debugging it by creating a .com file that's just under 32k and writing your code at the end (e.g. CS:0x7c00) and stepping through it with Debug.exe under DOS or in a command shell.

      Writing an entire BIOS is harder and requires a more in-depth knowledge of the hardware, but has very little to do with writing the boostrap code for an operating system. Installing an OS typically doesn't require burning new 'proms - you would always have the BIOS available to you when writing an OS for a PC in any situation I can think of.

  12. Richard Burgess's "Developing Your Own 32-Bit OS" by mosel-saar-ruwer · · Score: 5, Informative

    Richard Burgess's "Developing Your Own 32-Bit Operating System":
    http://www.amazon.com/exec/obidos/ASIN/0672306557/

    http://www.accu.org/bookreviews/public/reviews/d/d 000481.htm

    http://www.sensorypublishing.com/mmurtl.html

    Used to be published by SAMS, but they no longer list it. Now available as an online download.

  13. Don't do it for Intel by Dimwit · · Score: 4, Insightful

    Don't really do it for any modern architecture. Visit 6502.org and look at the sample operating systems they have there.

    Why? Because on your first (and second, and third, and forth...) you're not going to want to learn all about the inner workings of the Intel architecture. Segmented memory. *shudder*

    The 6502 is still small enough that you can wrap your head around it easily. 6502 emulators are plentiful. An operating system for a 6502-based machine would be small and simple, but still a useful tool.

    Once you get your head around that, then try the 6510 - same instruction set, but up to 16MB of memory.

    Finally, when you feel good with all that, try Intel, or Sparc, or PPC. My personal favorite processor to code for (assembly-language speaking) is Motorola's 68k.

    --
    ...but it's being eaten...by some...Linux or something...
    1. Re:Don't do it for Intel by squiggleslash · · Score: 3, Insightful
      Erm. You don't want the guy to learn about segmented memory so you recommend the 6502?!

      I would suggest the Z80, or if he wants to get exotic, the 6809. The 6502 is a horrible chip when it comes to memory - divides the entire map into 256 byte "pages". *shudder*

      There are plenty of older Z80 based machines, and it has proper, consistant, 16 bit addressing throughout. A much more pleasurable experience.

      --
      You are not alone. This is not normal. None of this is normal.
    2. Re:Don't do it for Intel by chthon · · Score: 3, Interesting

      There are also plenty of nice Z80 emulators. That way you don't need to reboot a machine every time and you have easier code stepping capabilities.

    3. Re:Don't do it for Intel by Gadzinka · · Score: 2, Insightful

      Why? Because on your first (and second, and third, and forth...) you're not going to want to learn all about the inner workings of the Intel architecture. Segmented memory. *shudder*

      Where have you been hiding for the last decade?
      Segmented memory is the thing of the past, deeply hidden inside real mode. since the times of 386 x86 architecture can use flat memory model (up to 4GB of course) if programmer chooses to. The memory mapping, pages are used for memory virtualization, they are not mandatory.

      Programming in asm for x86 is still PITA (unlike georgous m68k) due to limited number of (non)General Purpose registers, but you only write a handful of routines in asm, the rest is usually C or other higher (than asm) language.

      If I were to write OS from scratch, I would love to do it on m68k, or PPC. If only x86 weren't so indecently fast and cheap...

      Once you get your head around that, then try the 6510 - same instruction set, but up to 16MB of memory.

      Don't you mean 65816? 6510 is just 6502 with additional i/o register for memory banking etc. In c64 it was also used for driving tape i/o.

      But I admit, 6502 is cute little processor for fun programming. Only it doesn't give you any useful skills for _real_ OS design: no MMU, memory protection etc, things that are mandatory today even in embedded architectures.

      Robert

      PS You could even buy 65816 computer today in lovely ATX form factor, IDE disk interfaces and lots of other goodies, if you wanted to write os for this.

      --
      Bastard Operator From 193.219.28.162
    4. Re:Don't do it for Intel by Anonymous Coward · · Score: 0

      "Only it doesn't give you any useful skills for _real_ OS design"


      So doing something to simply satisfy one's intellectual curiosity isn't valid?

    5. Re:Don't do it for Intel by Cardbox · · Score: 1

      Wrote my own multithreading OS for an embedded 6502. Task switches beautifully fast because only 2 or 3 registers to save. Most instructions = 1 cloxycle. Basically RISC before RISC existed.

  14. Re:Richard Burgess's "Developing Your Own 32-Bit O by slothman32 · · Score: 2, Interesting

    I used that book. I would mod you up but no modding and posting. :( I made a mini "OS" which just went to PM, switched tasks, and did a little screen writing before going back to DOS. It wasn't a real OS but rather a program that uses PM. ButI learned all I needed to know from kindergarten, er that book. And I still have it.

    --
    Why don't you guys have friends or journals?
  15. Sigops by edalytical · · Score: 4, Informative

    Sigops How to Write an Operating System. This is a series that will walk you trough writing your own os. You'll have your own Hello World OS after you read the first chapter and you'll be multitasking by chapter five.

    --
    Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
    1. Re:Sigops by Anonymous Coward · · Score: 0

      Trough???

  16. Good question by JDWTopGuy · · Score: 1

    I just implemented the world's cheesiest threading system on a nonexistent computer. (It's a simple simulation I wrote.) It was hard yet fun. Maybe I'll get around to posting code some time.

    Gotta implement an I/O system...

    --
    Ron Paul 2012
  17. A great book... by BigZaphod · · Score: 2, Informative

    I have a book titled "Developing Your Own 32-bit Operating System" although i suspect it is out of print. You might try looking for it, though. The book takes you step-by-step through building an OS for x86. It's amazingly complete including all the source code. The guy even wrote his own compiler, if I remember right. Wonderful book.

  18. omg by Anonymous Coward · · Score: 5, Funny

    I have dreams of writing a toy operating system...

    Linus, is that you?

    So that Ask Slashdot you posted some time ago finally made it through the submission queue?

  19. Learn to write drivers instead by Kris_J · · Score: 1
    For the love of dog, we need more people writing drivers than we do writing OSes. Hook up with one of the interesting weird OS projects, like Contiki, and write some stuff for that. See if you can workout why the web downloader fails on some C64s. Or add support for the extra RAM in an RR-Net cart. Or if Contiki isn't your style, add support for the ECS to IntyOS

    Learning to expand an existing OS, and there are plenty of small ones to choose from, will teach you much more than building your own one from scratch.

  20. Minix might be a place to start by batemanm · · Score: 1

    Minix was designed to be small and easy to understand and there is a book called Operating Systems Design and Implementation which explains the inner workings in practical terms. NOTE I have the first edition of this book not the second. You can get the code for it and have a book which explains what the code is doing should be easy to play with and help you understand what is going on.

    1. Re:Minix might be a place to start by Anonymous Coward · · Score: 0

      You are a freaking idiot.

    2. Re:Minix might be a place to start by mar1boro · · Score: 1

      He may be a freaking idiot, but he's an amazingly
      insightful freaking idiot. /hands you a clue

      --
      -- "It was as if the paint factories had decided to deal direct with the art galleries." - Thursday Next
    3. Re:Minix might be a place to start by Anonymous Coward · · Score: 0

      How?

      You may hate Bush and/or think he's an idiot, but to say Bush didn't believe 9/11 was important the day it happened is just dumb.
      Nothing insightful about it.

      You guys both in the same grade?

  21. What Are Your Goals by osewa77 · · Score: 0

    The +5 modded posts have gone a long way in explaining the basics. The rest depends on what your goals for the Operating System are.

  22. Tanenbaum and Minix by james+b · · Score: 2, Interesting

    I really enjoyed Tanenbaum's Operating Systems: Design and Implementation. The whole book is basically a tour of Minix with lots of OS theory along the way. It's very *NIX oriented - signals and system calls etc, but there's some discussion of other ways of doing things.

    The nice thing about Minix is it's very easy to make sweeping changes to the OS, recompile the kernel, and see what happens, and the book helps explain how it all works.

    /james

  23. Really? by Evil+Attraction · · Score: 1

    "I have dreams of writing a toy operating system, as I know some people have already done in college."

    Who!?

    1. Re:Really? by NSash · · Score: 2, Informative

      Many colleges (including mine) offer Comp Sci. courses in which you design an operating system. It's not that uncommon.

  24. Linux Gazette article by DrMorris · · Score: 2, Interesting

    You may want to read an article in Linux Gazette:
    So You Wanna Create Your Own x86 Operating System?

  25. Do something new! by Walles · · Score: 4, Insightful
    Write it in an interpreted language. Have the interpreter run itself. I'm dead serious.

    The benefits would be that porting the OS and all programs running on it to a new platform would consist of porting the virtual machine only.

    Also, all code would be bounds-checked and stack-overflow protected, so a lot of today's security holes wouldn't be possible to create. With garbage collection, memory leaks would be a minor problem as well.

    To get a lot for free, you could base it on IBM's JRVM, a virtual machine for Java, written in Java.

    The drawback of not allowing C code to run natively is that there's a lot of software out there that'll be hard to support. This may be solvable, but I haven't given any thought to it so I don't know.

    --
    Installed the Bubblemon yet?
    1. Re:Do something new! by sl3xd · · Score: 2, Informative

      There are actual 'professional' OSes that do exactly this. (Or at least something close enough to be worth mentioning.) One such OS is called 'Pick', which is essentially BASIC, IIRC... It's also a multi-dimensional database, providing its actual 'usefulness'. The nice thing about Pick is that as long as the OS is ported to the platform you intend to run it on, every Pick program will run identically on every platform. So you're guaranteed that you won't have to do anything when your company decides it's moving from IBM to HP, for instance. Great stuff for mainframe work

      --
      -- Sometimes you have to turn the lights off in order to see.
    2. Re:Do something new! by sleepingsquirrel · · Score: 1

      I second that motion. I don't know how hard it would be using an interpreted language, but I would definately look into using something other than C. Think of how cool it would be if your OS was written in Haskell or OCaml or Erlang or prolog. If you pick one of those, you're pretty much guarenteed to be breaking new ground in OS research.

    3. Re:Do something new! by Anonymous Coward · · Score: 1, Funny

      Later versions of PICK OS were written in C. It is still being used by very stupid companies, and there's still commercial support for it. It should have been dead for decades (originally, PICK was created in the 1960's) but alas...

      Btw, if you ever have access to a PICK machine, logon and type 'echo' without parameters - and see if you can fix your terminal :)

    4. Re:Do something new! by bmac · · Score: 1

      And I'll give you the slogan:

      "What do you want to do today while you wait for your computer to finish a simple task?"

      And, if my intuition is correct, the JRVM may be an interesting intellectual exercise, but I bet it makes running a normal java program look like hand-optimized assembler by comparison.

      The main drawback of not using C is that you don't get a language that maps down to machine code such that your program runs well. Mark my words: the interpreted programming language for professional applications will die someday. Sure, you can use them for early development, but ya'd better compile that sucker for deployment.

      Remember, your intel/amd/ppc/... chip has an instuction set. All programs that do not run by executing those low-level commands are created by lazy programmers with inferior techniques and tools.

      Yeah, I know, here come the flames. But maybe I'm hotter than the flames already; that would make them feel like a nice cool breeze.

      Peace & Blessings,
      bmac
      www.mihr.com: for true peace & happiness

    5. Re:Do something new! by Walles · · Score: 1
      Regarding your performance worries, you are wrong.

      An interpreted language doesn't have to be run by an interpreter. It can be run by a just-in-time compiler as well. A just-in-time compiler (JIT) does exactly what any other compiler would. The only difference is that it is lazy and compiles only the stuff needed to run the program, and it does so on demand.

      After stuff has been compiled, you have the same code (assembly for your intel/amd/ppc/... chip) whether you compiled it using a JIT or a static compiler.

      If your compiler is lousy, performance will suck regardless of whether your compiler is a JIT or a static compiler.

      --
      Installed the Bubblemon yet?
    6. Re:Do something new! by bmac · · Score: 1

      Yes, you are absolutely right, but my problem is that I adhere to the old-school definition of "interpreted". And if, as per that def, you are interpreting the interpreter, you will be bogged down very quickly.

      Peace & Blessings,
      bmac
      www.mihr.com for true peace & happiness

    7. Re:Do something new! by tigersha · · Score: 1

      In the 1980's an OS was written in a lazy functional language which used lazy streams for I/O.

      The only compromise with regards to referential transparency was use of the McCarthy amb operator.

      I cannot recall the name right now but it was wrtten by John Henderson if I remember correctly.

      --
      The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
    8. Re:Do something new! by sleepingsquirrel · · Score: 1
      Wow. After a little googling, I found a Peter Henderson, who wrote a paper...
      Peter Henderson. Purely functional operating systems. In J. Darlington, P. Henderson, and D. A. Turner, editors, Functional programming and its applications, pages 177--192. Cambridge University Press, 1982.
      Which seems to cited by a lot of other papers, although I can't seem to find out more about it. I also found this list and this thread interesting. And there's also a paper on an OS written in ML
    9. Re:Do something new! by Walles · · Score: 1
      In that case, you were right.

      Regarding the JRVM, it has no interpreter AFAIK, it only has a JIT. As I've never done anything with the JRVM except read about it, it might still suck in a lot of ways, but it is a compiler so at least a naive interpreter won't be the source of its potential suckiness.

      --
      Installed the Bubblemon yet?
    10. Re:Do something new! by McDoobie · · Score: 1

      Umm...WRONG.

      There's an interpreter that's been burning C's ass for years when it comes to speed. It's called the Forth VM.

      Even when the code is good, I've rarely seen a compiled C proggy outpeform it's Forth equivalent in speed.

      The upside is that most Forths can run in a Virtual Machine or standalone, without an OS.

    11. Re:Do something new! by sl3xd · · Score: 1

      Look -- I still have nightmares about that OS. And the company that ran it.

      'nuff said.

      --
      -- Sometimes you have to turn the lights off in order to see.
    12. Re:Do something new! by bmac · · Score: 1

      Sorry, man, that's just *not* possible. You must be referring, as another poster did, to a just-in-time compiler. If it is a true interpreter, it is impossible to compete with a compiled program, unless the compiled program is written *very* badly.

      Sadly, most people at slashdot forget that just-in-time compilation is still *compilation*. Machine code is generated, so it is *not* interpreted.

      Now that I did some googling, check out:

      http://www.ussg.iu.edu/hypermail/linux/kernel/98 09 .2/0446.html

      And now for the penultimate question: where are all the Forth programs and operating systems?

      Peace & Blessings,
      bmac
      For true peace & lasting happiness: www.mihr.com

    13. Re:Do something new! by tigersha · · Score: 1

      Oh yeah, Peter Henderson. That paper is a classic but more because it was the first project to do a lot fo the work on lazy streams and IO. That and a old paper by Kahn which dates from 1972. Noweadays that approach is pretty much dead, Monads have taken over everything.

      --
      The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
  26. The way to go by JamesP · · Score: 1

    Operating Systems: Design and Implementation (Second Edition)
    by Andrew S. Tanenbaum, Albert S. Woodhull

    Very good book... Inspired Linus to write Linux based on Minix (the free OS that comes w the book)

    You may wanna check the Intel website for the 3 x86 manuals (or for the 6 manuals from AMD 64)

    --
    how long until /. fixes commenting on Chrome?
  27. uCOS by Phaid · · Score: 1

    One of my favorite projects in my sophomore operating systems class at university was to implement various little toy programs on Jean Labrosse's uCOS realtime operating system to illustrate various OS features like IPC and multitasking.. We did things like implement a "horse race" with two "horse" threads moving across the screen and an "announcer" thread which displayed positions, all synchronized by semaphores and communicating through mailboxes. Nothing earth shattering, but since the code for each thread and the related OS code was only a couple of pages of text, it made for a great presentation. Enough code to be fully functional, but not so much as to cause anyone to get lost.

    The nice thing about uCOS is that it is a very clean design that runs on simple platforms and can run as a task under another OS. We ran it on a 8mhz 286 running DOS. The source code is clean and well-commented, and there are a number of books written by the author which do a good job explaining the design and implementation and come with the complete source. It's a great way to see a simple implementation of task management on an OS and get a solid footing in the basics before delving into something like BSD or Linux.

  28. Operating Systems: Design and Implementation by RiverTonic · · Score: 1

    Operating Systems: Design and Implementation (Second Edition) by Andrew S. Tanenbaum, Albert S. Woodhull
    Link to the book on amazon

    --
    This is RiverTonic's sig.
  29. this can get you started by kousik · · Score: 2, Informative

    There is an excellent article by Krishnakumar, at least to get you through the bootloader part. Though he didn't write the next part(s), you can gather them from other sources.

  30. First step by Permission+Denied · · Score: 3, Informative
    People here are recommending all sorts of books and websites specifically catered to this project. When I did it, I knew of no such resources.

    Anyway, I'd recommend doing a google search for 386intel.txt. This is Intel's documentation for the 386 chip, including systems programming stuff. This is the file Linus used. The modern version of this documentation is available here for the Pentium III, split up in three. You'll need all three, but the third in the series is most relevant.

    After you get booting, you'll need some documentation for various devices when writing drivers. I used "The Indespensible PC Hardware Book" by Messner and it was pretty good. I guess there are also good websites available and you can always look at how Linux or *BSD does it.

    Anyway, you might be able to skip the Intel documentation if you use someone else's bootloader, but I don't recommend this. One of the points of this project should be to understand the machine inside and out from boot, so write your own bootloader and object code loader. Once it can run your C code, you'll get a feeling of satisfaction, which should be another of this project's goals.

    I used an older version of VMWare for testing, but I highly recommend bochs nowadays. Bochs seems designed exactly for this stuff, so you can run a debugger right away and you don't need to go through the older debugging route which was to write a serial port driver as soon as possible and get a remote debugger working over that (easiest way to do remote debugging in VMWare and real hardware).

    I'd recommend nasm for the assembler bits. It can do 16-bit code for the bootloader and it can spit out unadorned object code so you don't have to bother with parsing ELF and extracting what you need (although you'll need to do this eventually when you get to C, but you can at least delay that until after you start booting).

    One last thing - ignore the naysayers. It seems lots of people thought it important to post that you shouldn't be doing this but should instead be contributing some drivers to another project or something like that. Whenever someone in the open source community says this, they're almost always non-developers. Most of us write code on our own time because we find it satisfying and this is one of the most satisfying projects you can undertake. This project is also a kind of "coming-of-age" experience (for lack of a better word), like writing your own compiler or creating a GUI API or window manager. Users won't understand. That's OK. We understand.

    1. Re:First step by Mistshadow2k4 · · Score: 1

      Hey, I'm just a user and I understand. After all, why should I compose a new song or write a new book when there are already so many songs and books out there?

      --
      I dream of a better world... one in which chickens can cross roads without their motives being questioned.
    2. Re:First step by Permission+Denied · · Score: 1
      Hey, I'm just a user and I understand.

      Point well taken.

      I think the naysayers are those people who do not understand passion. In this case, it's a passion for understanding and controlling every minute detail of a machine, but anyone who is passionate about something - be it music, writing, mountain climbing or even font design or organic chemistry - can understand the motivation. I'm not really into performance cars, but I think I can understand the drive behind the hotrodders who try to tweak every last bit of performance out of their machines.

      Sadly, I find few people who demonstrate passion. It seems like most people would rather have me bug-fixing drivers for their new-fangled 3-d video card than writing a window manager for my own use, just like most people would rather have their brake pads changed by the hotrodders instead of leaving them in peace.

      I've found some solace in open source communities as they seem to attract a higher-than-usual percent of people who understand passion, both programmers and users.

    3. Re:First step by Anonymous Coward · · Score: 0

      Yes, it's just a shame that so much of that passion is misdirected for a certain person's political ends.

  31. MMURTL - Developing Your own 32 Bit OS by ChaseTec · · Score: 1

    There used to be a book called Developing Your own 32 Bit Operating System that went out of print but it's be rereleased as MMURTL. You can order it in PDF or dead tree format. Also you might want to check out my site. I've got a bunch of links to osdev resources.

    --
    My Hello World is 512 bytes. But it's also a valid Fat12 boot sector, Fat12 file reader, and Pmode routine.
  32. OOPweb tutorials... by Hobart · · Score: 1
    You can learn a lot (there are Operating Systems courses for free) from here:
    http://oopweb.com/
    --
    o/~ Join us now and share the software ...
  33. Looking at doing the same thing by rjshirts · · Score: 1

    If anyone knows where you can find info on the PocketPC chips, any and all of them, for iPaq's and HP's old Jornada, That would be appreciated.

  34. Apple ][ by stuffduff · · Score: 1
    When I got my Apple ][ it had onboard 16K of ROM. Somewhere in that manual was a funky command:

    >CALL -151

    This lead to the system monitor ROM. From here I discovered how to dump the content of the ROM with the hex address and an 'L' something like:

    *FF00L

    After a bunch of listings I found the address which was hard wired in the system as the first instruction to be executed when the computer was powered on; and from there basically reverse engineered the whole machine in order to get a feel for why it did what it did.

    Now a days I'd suggest that you look at your hardware's BIOS and the calls made available to the operating system by it. Most but all os's work off the bios.

    For some real fun, grab an 8080 system and reverse engineer it. Remember, Linus took a course where they looked at MINIX for the 286, all he wanted to do was make it work on his 386 and use the full capibilities of the processor.

    --
    "Can there be a Klein bottle that is an efficient and effective beer pitcher?"
  35. Follow OS Project course at my university by Turmio · · Score: 1

    If you want to learn about implementing operating systems, you could follow Operating Systems Project course just started at my university. All the materials, exercises and documentation (ignore the bits about ordering handouts, needed manuals are provided in PostScript and PDF) are in English and available to anyone but you'll miss the lecturing course that takes place at the moment and which is intended to be taken at the same time (they use Tanenbaum's Modern Operating Systems, 2nd ed.) and you won't get any feedback for the work you do of course. You use BUENOS (Buenos is a University Educational Nutshell Operating System). It's a small skeleton OS, developed for this course. You have a framework and development environment but during the course you'll implement the guts of the OS. Looks very interesting stuff. Unfortunately due to time constraints I couldn't take the OS project course this spring, just doing the lecturing part.

    If you want something runnable on your PC, then this probably isn't what you want, though, but for learing about operating systems, it might be useful.

  36. os tools by Anonymous Coward · · Score: 0

    You should look at the OSKit, which has the low-level bootstrap to get you started. You can replace parts as your OS progresses.

    See http://www.cs.utah.edu/flux/oskit/

  37. Its All The Same by osewa77 · · Score: 1

    The effect of building an OS from scratch in 2003: Nothing (except personal pride?)

    The effect of complaining about SCO: Nothing (except community pride?)

    Difference between the two: Nothing! (except the details?)

    1. Re:Its All The Same by Anonymous Coward · · Score: 0

      Bet you would've said the same thing in 1989.

  38. bullshit by Anonymous Coward · · Score: 0

    Ignore this clown. Do something on a tiny scale, something embedded. "Something" is the key here, eh? And there's nothing wrong with learning ASM, though not absolutely necessary.

  39. Re:Linux by n0dez · · Score: 1

    Wrong! Linux isn't an operating system; it's just a kernel. You need the Linux kernel + the GNU userland to have a *complete* OS.

  40. First things first by sjames · · Score: 1

    First, look at the various OSes already out there. There are a wide variety for various hardware and with various underlying archetectural philosophies. There's a lot more to an os than hacking together a bootloader et-al. For example, do you want it to be POSIXish? Micro,Mono,Exo kernel? None of the above? What is it's central theme? Persistant objects?, namespaces? files?

    What is your primary interest? Do you want to get into the nuts and bolts of the hardware, the semantics of a system/OS, or both?

    If your primary interest is the semantics of the OS and archetectural aspects, consider writing a hosted OS. That is an OS that runs as a user application(s) on another OS such as *BSD and/or Linux. With careful abstraction, you can start out hosted (with the MANY advantages for debugging that presents) and later migrate to the bare metal by replacing OS calls with low-level code.

    By going that route, you'll avoid many frustrating days of having nothing at all working after a bunch of ASM code (depending on the sort of challenge you're looking for, that could be good or bad).

    Some OSes can run themselves. With the user-mode-linux port, linux is moving in that direction. Mainframes have been doing that sort of thing for a long time.

    Starting with a hosted OS will also remove much of the grunt work from bootstrapping the OS. Not bootloading, bootstrapping. That is, producing the binaries for the OS before the OS itself exists.

    That bootstrapping process will be quite eye opening. Do you want to do that the easy way or the hard way? The hard way is to hand assemble a simple monitor and assembler and load up the raw binary code. Then write a simple compiler in assembler, then a more advanced compiler for the simple one to compile. Now, compile a more advanced monitor. Use that environment to generate the OS. As an alternative, use the existant environment of a modern OS to create a hosted OS. If/when ready, use the hosted OS to generate the bare metal version of the OS.

    If you want to check out the lowest level of the system, see LinuxBIOS. LinuxBIOS is a complete replacement of the firmware BIOS in a PC. Unless you want to design your own CPU, you won't get any lower level than that.

    An interesting line of thought there is that "Any sufficiently advanced bootloader becomes an OS". The conclusion there is to use Linux as that OS! In the interem, since flash chips aren't big enough, there's various bootloaders loader by LinuxBIOS including etherboot, openfirmware, filo, and a few things built with bare metal toolkit.

    If you choose to implement (or emulate) POSIX semantics, you get to use GNU's userspace. In that case, glibc becomes the glue. Otherwise, you might use them as a guideline, or just hack and patch until they run.

    Keep in mind, you never know where it might lead. It'll probably join the ranks of the many toy OSes out there that are used by one or two people. Of course, That's where Linux thought his kernel was heading when he started it. Much to his surprise (as I understand it anyway), it took off BIG from there :-)

    With the above in mind, how much does the potential (however small) for it to take off like that matter to you? If it matters, you might consider doing something really different. That will tend to remove the middle of the road and cause it to either take off or be run only by you. Which of those happens depends in part on your design and in part on random chance.