6 ms·
Show HN: xOS – a 32-bit OS for the PC
- roryisok 10y agoPretty nice technical achievement. I'm always excited at seeing an entirely new OS, not based on Unix.
- wolfhumble 10y agoEven though I haven't tested it, not bad coming from a "15-year-old computer hobbyist". Congrats!
- qb45 10y agoAnd includes XFS implementation in just half KLOC, not bad at all ;)
- jesuslop 10y agoWhy not 64 bits?
- DSMan195276 10y agoI donno if this is a serious question or not, but x86-64 is very much an extension of regular 32-bit x86, just more complicated. For something like this there's little reason to attempt 64-bit when 32-bit is much easier and will essentially result in learning the same concepts.
- johncolanduoni 10y agoI messed around with writing OSes when I was around the same age, and I found x86-64 to not have much of an overhead relative to plain x86. Getting into long mode itself is just a tiny bit of boilerplate at the very beginning. If you didn't plan on using paging then you need to do a bit more work to identity map everything, but if you already did the extra virtual address space means you can just map all physical addresses (that are hooked up to anything) linearly somewhere and not have to play games with mapping/unmapping things just so the kernel can access them briefly. You lose the ability to have the processor save state on context switch for you via the TSS, but that's not very hard to do yourself either. The ins and outs of running something in compatibility mode are quite complicated, but there's no reason to involve yourself in that if you're writing your own toy OS. Overall I'd say 32-bit dodges a few things, but I wouldn't call it much easier.
- DSMan195276 10y agoA few things: x86-64 uses a 4-level page-table, which is much more annoying to get right then a 2-level page-table if you're not familiar with paging or haven't dealt with it before. I agree about TSS - nobody really bothers using it anyway. That said, x86-64 has a bit more state to handle when doing a context-switch (Though nothing very extreme) x86-64's calling convention is more complex then x86's calling convention. For this project it doesn't really apply because it isn't followed anyway, but for a C project it would come into play. IMO, another big issue with doing x86-64 is documentation - x86 has tons, x86-64 has comparatively little. I would definitely agree that if you know what you're doing the differences aren't huge, but if you don't know what you're doing I think you'll definitely have an easier time getting stuff working with x86.
- riscy 10y agoThere are real benefits to using x86-64 over x86, namely, x86 is starved of general purpose registers. There are many more registers available on x86-64.
- DSMan195276 10y agoTrue - that obviously applies more to writing assembly then C, but of course this is an assembly project. Depending on your coding style though I'm not sure how much it would really come into play - x86 is registered starved, but it also allowed memory addresses in lots of instructions, allowing you to avoid putting things into registers in the first place. You get twice the number of registers with x86-64, but his code doesn't really appear to be suffering for not having enough registers to begin with.
- jesuslop 10y agoI was about to respond (and from rusty personal memory, correct me if wrong) that having larger than 4Gb segments seems fit for todays ram dotations but this answer is even better.
- eximius 10y agoIIRC, turning on 64bit mode brings more complexity? I only briefly looked at this stuff last year. Someone can correct me if I'm wrong. But for someone learning this stuff, limiting the complexity you have to deal with is a good idea.
- Someone 10y agoI would guess for the same reason "PS/2 keyboard and mouse" have been implemented, but USB hasn't. If you want to write an OS with a GUI on modern x86 hardware from scratch, there is an insane amount of stuff you have to do to support a generic keyboard, mouse, and display before you can do any work on your OS proper. He's not alone in this, but the way; another OS author wrote "it probably never will support anything other than AT-harddisks, as that’s all I have :-(."
- lowpro 10y agoA 15 year old Egyptian kid made a new OS in asm who wants to study medicine. Sounds like he needs to go to SV, I think he'd fit right in.
- PeCaN 10y agoNah, he's a pretty bright kid, I'd hate for his talent to go to waste.
- fifteenforty 10y agoI'd hate to see his talent wasted in medicine. Edit: I should elaborate: it's hard to put these sorts of analytical skills to use in medicine, without banging your head against the wall. I've met some brilliant software developers who happen to be doctors. They are universally frustrated by their working environment.
- duaneb 10y agoA win for SV is a loss for the rest of the world. Don't encourage this. SV is already encouraging bright people to sell ads instead of improving the world.
- anta40 10y agoA 15 yeard old writing OS, in assembly. That's a pretty impressive feat, I think. Sometimes I envy those people who made such achievement at young age. When I was 15, I'm not interested in learning computer programming yet. Mostly just played games, like Duke Nukem 3D or :/ Curiosly, it was a book about computer virus programming (obviously in assembly) which hooked me into coding :D
- milanove 10y agoHe also created a remake of this in C called "mos". Kind of irks me that he does "if(var == true)" instead of "if(var)" in certain spots though.
- saghm 10y agoHe's 15, I think it's okay to cut him some slack
- milanove 10y agoHe was able to make his own operating system though. However, I agree. In comparison to his achievement, simple code style choices are nearly irrelevant.
- deleted 10y ago[deleted]
- morbidhawk 10y agoWhy is the second version so much better? To me I think it's just a preference of the person reading the code. That it is true is implied, being explicit that it evaluates to true might be more clear to him when he goes back and reads his code.
- codazoda 10y agoI prefer the longhand version; seems a tiny bit more readable. We're talking about C, but it becomes important in some higher level languages. Just my personal preference though.
- jv22222 10y agoBuilding stuff like OS's, frameworks, libraries, from the ground up is always a very worthy pursuit. It just makes you so much better at dealing with all the shit your future career will throw at you. Congrats, great job!
- ratfacemcgee 10y agodamn this is impressive, regardless of age! I'm 31 and I sure as shit couldn't do this!