Live data from Hacker News

Roll Your Own UNIX Clone

jamesmolloy.co.uk

11–20 of 44 posts

Re: Roll Your Own UNIX Clone

#12
post #10

I'll just leave these here... http://www.intel.com/products/processor/manuals/index.htm [disclaimer: I'm an OS/kernel dev]

I gotta ask...if I go do this sort of thing on my own, I might produce something that won't segfault or oops()...if I were to walk into a job interview for an os/kernel dev job (the kind that rand say I did write a crappy primitive kernel would that look good or bad? I've been working for almost 3 years now and this is an area that I would like to move into.

I'm not in industry but in academia so I'm hesitant to say anything concerning commercial development. I can't ever see it being a negative thing, but the difference between a toy kernel like he is proposing and a real system is larger than many people think. For example, knowing how to use the GDT and the LDT is definitely required, but knowledge of SMP design and general hardware architecture (think chip design, memory hierarchy, etc) are equally important. If you were looking for a career in systems design, definitely read the Intel Manuals cover to cover -- then go look at the Linux/BSD kernel to see where things were explained so poorly that they may as well be wrong. I would also highly encourage you to take part in a systems open source project (since I work on virtual machines, I would of course suggest Xen or QEMU).

If you like, a much simpler version of the Linux kernel, Kitten OS[1], is used to run at Sandia and in sequence with the Palacios academic virtual machine[2], which is what I'm working on. It may be worth looking at, although I still highly recommend that you look into actual production code.

[1] https://software.sandia.gov/trac/kitten

[2] http://v3vee.org/

Re: Roll Your Own UNIX Clone

#13
post #9

I'll just leave these here... http://www.intel.com/products/processor/manuals/index.htm [disclaimer: I'm an OS/kernel dev]

But you can bootstrap a cheap Unix with chapters 5-10 of this: http://www.logix.cz/michal/doc/i386/ Getting into protected mode and exec'ing processes in their on private space has been done with ~4 pages of asm.

Don't run in v8086 mode unless you have to (BIOS boot in Intel VMX). Just go directly to PE or LME as the new docs tell you. It may be interesting to look at the history though.

Also, while devs have to write portable code -- don't bother. It'll save you a bunch of time if you just write the IA32e specific asm code.

If anyone has any interest, I can also post my adaptation of an asmx86 vim syntax file I hacked up from something I found on Stack Overflow. It's not that great, but it does at least fix some of the register highlighting.

Re: Roll Your Own UNIX Clone

#15
Whenever I think about doing something like this, I always get stuck up on x86 ASM. There don't seem to be many books on ASM out there, and the ones I could find in the bookstores were all written around MASM which, of course, does not work on Mac OS X.

Any ideas?

Re: Roll Your Own UNIX Clone

#16

Whenever I think about doing something like this, I always get stuck up on x86 ASM. There don't seem to be many books on ASM out there, and the ones I could find in the bookstores were all written around MASM which, of course, does not work on Mac OS X. Any ideas?

The difference between Intel/MASM syntax and AT&T/GNU syntax is rather superficial[1], so with a little squinting you can use a MASM book with the GNU assembler. Newer versions of the GNU assembler also come with a directive .intel_syntax so you can write your learning programs in MASM syntax.

[1]http://www.ibm.com/developerworks/linux/library/l-gas-nasm.h...

Re: Roll Your Own UNIX Clone

#17

Whenever I think about doing something like this, I always get stuck up on x86 ASM. There don't seem to be many books on ASM out there, and the ones I could find in the bookstores were all written around MASM which, of course, does not work on Mac OS X. Any ideas?

Here's a trick to help get you started:

Write a relatively simple C program that does something useful that you understand thoroughly, then generate intermediate assembly code from your C compiler, with optimization turned off.

That way you get a problem that you already know how to solve in a .s listing that you can inspect and modify to your hearts content.

Then try to optimize it, make it run quicker by rearranging stuff.

You'll learn lots that way and the barrier to entry is low.

Re: Roll Your Own UNIX Clone

#18
Thats great and all, but hes forgetting two very important aspects of a real OS: drivers and software.

Ok, hes not building a real OS, but rather a toy OS (presumably for the learning experience), so these things are not so much of an issue. Its actually a good article, IMHO, and I wish it had been available a few years back when I tinkered with writing my own toy kernel. The "Roll your own unix clone" title given here is pretty misleading though.

Re: Roll Your Own UNIX Clone

#19

I'll just leave these here... http://www.intel.com/products/processor/manuals/index.htm [disclaimer: I'm an OS/kernel dev]

The System Programming manual and the Instruction Set references (I do not have a copy of the Application Programming manual, unfortunately, and don't really want to read it in PDF form) are exceptionally good and have helped me back when I used to mess with toy kernels and also helped with Uni assignments. I'd definitely recommend them to anyone who is interested in kernel or assembly development.

Re: Roll Your Own UNIX Clone

#20
Please don't! Build something original. It really is possible!

Once you've built a UNIX clone, you have polluted your mind as an OS designer. I did so (as a standard college homework assignment) and it took me years to shake the crud out of my head.

As for the tutorial, it is very well written, but x86-32-centric and therefore worthless. There are nontrivial differences between x86-32 and x86-64 from the standpoint of an OS author who wants to make full use of the latter's capabilities.

Post reply on HN