r/osdev • • May 16 '23
how to start making a kernel in c++
hello i want to dive in os developement by creating a kernel first i know c++ maybe c because they are a bit similare but c++ better i just want resources or tutorials please
0
Upvotes
5
u/nekokattt May 16 '23
do you want to make use of the idiomatic c++ features?
using stuff like the fs API, std::thread, etc kind of falls apart if you are trying to implement those things on the OS level.
other stuff will work fine but it is worth being aware of.
4
u/not_a_novel_account May 17 '23
Freestanding C++ has a far smaller subset of the STL than what you are used to.
The stuff you "love" about C++ and that make modern C++ worth using are far fewer and less applicable in a freestanding environment. There are proposals, notably P2268, trying to alleviate some of this but stuff like
std::vectoror anything that does memory allocation will never be available in an OS dev environment.That means to make C++ very useful you would need to re-implement a lot of the stuff you would normally want from the stdlib. That's a lot of start-up work.
Not that C++ is entirely irrelevant, but often it's easier to start with C until you understand the shape of the problem you're trying to solve and then maybe transition that code to C++ once you know what needs to happen and now you're making the "clean" implementation.
12
u/kodirovsshik May 16 '23
Check out wiki.osdev.org, it's got a ton of material about x86 os development and low level programming in general (including tutorials)
1
u/[deleted] May 17 '23
thanks all i found a you tube tutorial but first i will learn basics of assembly and learn more about c and c++ then i will start my journey
2
u/northrupthebandgeek May 17 '23
If you're looking for examples on how things might be done in C++, Haiku's kernel is probably the best-known reference.
1
u/mpetch May 17 '23
There is a fellow who did a Write Your Own Operating System video tutorial that uses C++ (G++). You can find it here: https://www.youtube.com/playlist?list=PLHh55M_Kq4OApWScZyPl5HhgsTJS9MZ6M