Hi,
I am a complete beginner to OS development, and I am an intermediate developer in C++ and I don't know ASM.
So I was wondering if I could make an OS in C++. I am a complete begginer so any help on OS Design or programming would help!!!
Many Thanks!
Harry.
Is it possible to write an OS completely in C++???
Is it possible to write an OS completely in C++???
Reflect Desktop Operating System - ' You only remember the name of the OS when it crashes '
Re: Is it possible to write an OS completely in C++???
Yes you can make an OS in C++, but you will need a small amout of assembler (about the same as for a C kernel). For an idea of how much assembler you need, my kernel has long gone past the point where I need to use assembler (all the necessary assembler is more or less there) and currently I've got:djnorthyy wrote:Hi,
I am a complete beginner to OS development, and I am an intermediate developer in C++ and I don't know ASM.
So I was wondering if I could make an OS in C++. I am a complete begginer so any help on OS Design or programming would help!!!
- about 7000 lines of C-code, headers and comments included
- about 500-600 lines of assembler, comments and inline-asm included
Well over half of the quoted amount of assembler is comments, so the real amount is probably somewhere around 200 instructions. Most of this is very simple stuff, like PUSH/POP/ADD/MOV and such.
To me that basicly indicates that you'll need to understand the processor well enough to write assembler, but you don't really need to know assembler as such, since the amount is small enough that you can lookup almost every instruction from the manuals separately.
---
As for advice, before anybody comes in an suggest you start writing a bootsector, I use my opportunity to say DO NOT. Instead, get yourself GRUB, read the multiboot specification, look at the example "Hello,World!" kernel included, and try to get it boot.
After that, write some basic console output routine. It mainly needs to dump stuff to screen, and scroll when it hits the bottom of the screen. Our Wiki should have info about how textmode screen works on PC. If you feel like it, write a printf as well (makes it easier to provide good diagnostics) or C++ style, if your console is a class, make it accept strings and numbers with overloaded operator<<. Which ever you prefer.
Once that works, you need interrupts/exceptions. When those work, you might want to start wondering about paging. Once that works as well, and you've written a malloc/free (or new/delete for C++ style), it's probably good idea to make a scheduler, so you can have multiple threads. I'd also add semaphores and timers at this point.
Once those are done, you can start worrying about userspace programs, or device drivers, or filesystems, or whatever you feel like is the most important thing.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
Thanks.
Thanks for that!
Cheers,
Harry.
Cheers,
Harry.
Reflect Desktop Operating System - ' You only remember the name of the OS when it crashes '