Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Wow, from the queue presentation this OS looks even less usable than DOS (MS aka Q). Why would the CLI terminate when it runs a programme? How do you run more than one programme at once? If each core polls the run queue does that mean that it busy cycles when there is no more work to do? Won't this waste energy? (A sin in the HPC world). Does it do the same for IO? IO request completion on a slow and/or busy disk could take as long as 50ms, for a 2.5GHz CPU for example this is 125 million clock cycles. Will the CPU busy cycle this as well?

If you want a simple OS that fits a lot into a small space, why not get a copy of the Lions' Commentary and translate the edition 6 kernel into asm. If you wanted to go gung ho you could add a simple BKL, demand paging and a network stack to complete the job. You could probably do all the above and keep it somewhere close to 20,000 lines of assembly (excluding drivers).

If you are looking for an education doing the above will probably do you just as good a job as trying from scratch.

Lions' Commentary on UNIX 6th Edition, with Source Code http://en.wikipedia.org/wiki/Lions%27_Commentary_on_UNIX_6th...

The Art of Computer Programming http://en.wikipedia.org/wiki/The_Art_of_Computer_Programming



TAOCP and the Lion's commentary? Edition 6 kernel into asm? Why?

You're working hard to sound old-school, but these are just random allusions. TAOCP is not especially relevant to OS programming, and translating _all_ of an OS into asm to make it "fit a lot into a small space" is just... plain... stupid...

You will make the code smaller (as compared to gcc -Os) in a few places; you will likely give yourself a hernia maintaining it, and you are likely to get considerably worse performance than a decent compiler will.


To expand on that: it's fun to take a look at the assembly code "gcc -O3" produces. It's absolutely wild: even after staring at it for a while, I often have no idea what clever tricks gcc used to turn the C code into that assembly code. It does a better job of making fast, compact code than I suspect I ever could.

There was a time when C compilers generated crappy assembly code, because that was easy for the compiler writers. That time is long past, with exceptions for a very few situations where the compiler misses a trick that a human can do.


Well, sometimes it's fun. Other times it's utterly horrible. gcc doesn't always do a wonderful job and the maintainers sometimes just don't seem to care - induction variable optimizations and gcse were broken in 4.2 and 4.3 and the issue was left unfixed, with clear examples of obvious FAIL on simple and performance-critical inner loops.

However, this doesn't apply so much to OS code, which doesn't have nearly as much opportunity for micro-architectural shenanigans either way. Typically something like -Os does a good job of handling operating system style code.

Hand-coding OS asm remains a fine example of pointless tedium for the most part. There are clear places where you absolutely need asm, of course, but writing stuff in asm that can be perfectly well done in C is like cleaning out the barracks room bathroom with a toothbrush.

This was one of the early innovations of UNIX (high level language use), so there's something wildly anachronistic about this guy's suggestion. It's like suggesting that you rebuild grandpa's Studebaker so that it can be drawn by a team of horses.


I guess I didn't elucidate my ideas properly. My point was _if_ you wanted to write an asm OS and learn from it, following in the steps of the masters might be more productive and enlightening. The PDP11 is sufficiently different from modern architectures, the scheduler as written in Lions relies on undefined CPU behaviour to work, that it wouldn't be a straight re-write; there is plenty to learn here. It would mean however that you would avoid plenty of unnecessary dead ends.


The MIT guys have already created a port?/reengineering? of 6th edition, check out xv6: http://pdos.csail.mit.edu/6.828/2009/xv6-book/index.html


That links to an older version - the current version seems to be at http://pdos.csail.mit.edu/6.828/xv6/




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

Search: