Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Bare Bones OS Kernel Tutorial (osdev.org)
132 points by fogus on May 24, 2011 | hide | past | favorite | 26 comments


There is a Phrack article with a full kernel.

These things are dime a dozen. I cut my teeth on Doug Comer's Xinu, still one of the more accessible ones, if a bit over-commented.

Outside the x86 and ISA architectures, OSes are just algorithms. All the magic goes into probing devices and chanting legacy BIOS incantations :-| The first seconds, from moment you press ON until you see the OS splash screen, the machine runs through 30 years of PC history.


Is this the Phrack article you are referring to?

Protected mode programming and O/S development

http://www.phrack.org/issues.html?issue=52&id=17#article


yes


I just wasted ~2 hours reading various pages of this wiki, it's a great resource.

My question is: Other than the obvious educational value, is there something concrete a beginner can do with a minimal kernel? What beginner projects would you recommend?


My plan for a summer project is going to be to first make a really basic OS. Then I'm going to bootstrap my own language from nothing like this guy: http://homepage.ntlworld.com/edmund.grimley-evans/bcompiler.... Then I'm going to make graphics with something like mode 13h. Maybe not beginner projects, but extremely interesting and challenging.


Nobody wants to take a look at pintos? http://www.scs.stanford.edu/10wi-cs140/pintos/pintos.html


Perhaps for something that was embedded (like an OS for ARM microcontrollers or something), but a desktop or server OS is unrealistic.

The problem is drivers - unless you manage to port Linux drivers or something to your OS, it's never going to be able to use more than an extremely narrow cross-section of hardware.

It very good for the educational value though! Making a kernel that boots a simple shell, and eventually runs statically linked executables is possible in a few months if you spend a lot of time on it (and a lot of that time is research, not coding).


I'd say handling interrupts, paging/the memory subsystem, filesystems and scheduling were all pretty worthwhile.

It's important mostly not to worry about the finer details/getting things perfect - you almost certainly won't be able to make anything which is practically useful but it's an awesome learning experience :)

One thing that is very helpful to stop you from tearing your hair out is getting hold of a function to do sprintf() early on - it's no fun to write, just messy, and it lets you do primitive debugging. This seems like a good shot, despite the sketchy looking URL: http://read.pudn.com/downloads97/sourcecode/unix_linux/39644...


I like this series; it covers getting a bare metal kernel running on ARM QEmu:http://balau82.wordpress.com/2010/02/28/hello-world-for-bare...

ARM is generally a lot more sane than x86 when it comes to writing close to the metal, although there's a lot less info about stuff out there. Often reading the manuals for the chipset will get you what you want though..


ARM's problem is that every board has a slightly different variant...different instruction sets present or absent, different boot code, and the like. Linus was throwing a fit a few days ago about merge conflicts in a bunch of tables (which he thinks should not even be in the kernel), and noted that 35% of platform-specific code in the kernel is ARM-specific.


Whenever I hear about Operating Systems, it reminds me of a comic on how a programmer evaluates the resume of another programmer and one of the items is OS / Compiler development experience is highly valued.

So, on a related note, would you be suitably impressed with a resume if it lists that it has a bare bones file system / shell implemented ?



File system: yes. Shell: no.


A shell is a dsl for calling fork/exec.


I developed a kernel during most of my teen years. The source is still up on sourceforge at http://cefarix.cvs.sourceforge.net/viewvc/cefarix/source/ . Hopefully it can be of some help to you!


What a great site. Besides the subject matter, I like the general idea of focused breadth and participation.

Is anyone aware of a similar site for compilers? Or anything else? I've never liked wikipedia's wiki books, their coverage can be spotty, but I like that idea too.


This could be useful for embedded development. Booting a new kernel on any embedded device is tough. This could be handy if you're new trying to debug why your board isn't booting up.


Unfortunately, this is very x86 device dependent and most embedded devices are not x86.


tl;dr: my hobby OS: http://github.com/rikusalminen/danjeros

Last summer I got inspired by this article and stumbling on the intel processor manuals (http://www.intel.com/products/processor/manuals), which I kept on reading for a few weeks and then I started hacking with my own hobby OS project.

First I created an all-assembly boot sector mini-kernel that booted into 64-bit long mode and then did a small multitasking test case , first co-operatively and then pre-emptively using timer interrupts.

Then I started over, this time with C and using a proper multiboot bootloader like Grub. I hacked with it for a while but my x86_64-specific code and kernel code were all over the place and it needed a reorganization.

So, recently I reorganized my code, added a CMake-based build system and put it in a Git repo, here: http://github.com/rikusalminen/danjeros

It doesn't do a whole lot, but it's a solid base I intend to continue when I have some time for kernel hacking. I'm sorry there's nothing in the README-file, I should at least add instructions for building the required cross-compiler (for TARGET x86_64-pc-elf), building (requires CMAKE_TOOLCHAIN_FILE for cross-compiling) and running with qemu and debugging with gdb.

If someone actually read this far and got inspired from the osdev articles, like I did, why not take a look at my DanjerOS project.


No one here has mentioned Minix, so I'll go ahead. It's another fun system to play around with, and quite accessible. It's also enough to do 'real things', to some degree.


Bringing a CPU up to run a program is quite a technical challenge.

One of these years I'd like to create a mini Lisp multi-threaded kernel.


not really a kernel. try my microkernel: http://git.l4dev.org/


sure it isnt a full kernel. Its just a bare bone. Something where you can expand upon.


Just FYI: this "Bare Bones" does not refer to the long-time Mac OS software developer responsible for BBEdit, TextWrangler, etc.


To be honest, "bare bones" is a fairly generic term...


Yes, but as a daily BBEdit user, it was the first thing that crossed my mind. Evidently I am the only one.




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

Search: