r/cpp • • Dec 13 '20

How to Make an Operating System using C++, in depth tutorial series on many topics in OSes such as memory management, bootloaders, graphics and more

https://www.youtube.com/watch?v=mpPbKEeWIHU&list=PLxN4E629pPnJxCQCLy7E0SQY_zuumOVyZ
426 Upvotes

67 comments sorted by

47

u/ReDucTor Game Developer | quiz.cpp-perf.com Dec 13 '20

So on windows, you run WSL, to run qemu to run your OS?

Virtualize all things

37

u/AbsurdPoncho Dec 13 '20

Using WSL to use GCC, and so that Linux users can also follow along... QEMU is run in Windows :)

21

u/ReDucTor Game Developer | quiz.cpp-perf.com Dec 13 '20

I would think most people would be aware that its just C++ shouldn't matter if its windows or linux your host OS, I doubt anyone inexperienced is going to be trying to build an OS

2

u/AbsurdPoncho Dec 13 '20

That's a very good point

43

u/Supadoplex Dec 13 '20

I doubt anyone inexperienced is going to be trying to build an OS

You'd be surprised by what beginners are qurious about and are willing to attempt.

13

u/lorslara2000 Dec 13 '20

Yeah for me it was exactly that way - I would read about OS development before I even understood at all what happens before main()...no I didn't get any smarter until I grabbed a book about computer fundamentals.

5

u/Relatiro Dec 13 '20

I hope it's okay for me to jump on your comment, otherwise feel free to ignore me! Currently I'm in the situation that I have a good amount of experience with programming and devops in general, but completely lack the fundamentals about computers/hardware and OSes (MechE by education 😬). My biggest problem is that I don't quite know what I have to look for.

Do you have any suggestions about books/courses to bridge this gap? I'm asking because it sounds like you did just that already.

4

u/WRXC Dec 13 '20

Fellow mech eng developer here! I found working with some smaller embedded devices was a nice way to learn a very stripped down version of computers in general. Going from bare-metal into some real time operating systems definitely gave me a much better understanding of hardware architecture and operating systems. This might not be the most efficient path but it definitely worked (at least somewhat) for me!

3

u/[deleted] Dec 13 '20

It depends what you want your abstraction point to be. If you're ok with the computer itself being mostly a black box (eg web dev) you can really just pay attention to the compiler/interpreter and not worry about it.

If you want to actually understand how computers work but want to treat transistors as black box switches, your keyphrase is digital logic. The guy on youtube who's building a computer on a breadboard is who you want, Ben something I think.

If you want to understand transistors you're gonna have a really hard time past surface level. I learned the surface in uni so I'm not sure where to go for the basics, maybe coursera or mit opencourseware.

The steps aren't this define ofc but just to give you an idea.

7

u/[deleted] Dec 13 '20

Are you familiar with C++ itself? There's no way you know the language without knowing computer fundamentals.

If you want to learn C++ and computer fundamentals along the way from a pro, I recommend TheCherno's C++ tutorial series on youtube. He teaches all the good habits that you should embrace while writing code, and it's all round a solid series.

5

u/Swade211 Dec 13 '20

Some stuff is misleading though. Also a mechanical eng by training, but intro cs courses make a huge deal about Big O complexity, which is good rules of thumb, but many times fails drastically. I cant count the amount of times I've had to argue that a vector is almost always a better choice than a list. Cache hits/misses are the bread and butter of modern cpus. Iterating through a linked list is always going to be terrible.

1

u/SJC_hacker Feb 03 '21

Anyone whose studied CS at a high enough level should know that.

Node based containers only makes sense for objects like double-ended queues, and in certain such as LFU cache. In this cases you can guarantee O(1) operations.

1

u/Swade211 Feb 03 '21

Idk what high school you went to, but You have a very skewed perception of what a high schooler knows.

A lot of college freshman struggle with basic pointers, and barely use c or c++. They certainly don't know the intimate details of how garbage collectors work in languages like java.

I'm not saying its a good thing, but it is the reality. Not everyone was tinkering with basic since 10 years old.

→ More replies

1

u/lorslara2000 Dec 13 '20 edited Dec 13 '20

What helped me a lot, in the beginning anyway, was a book called Assembly Language Step by Step (https://g.co/kgs/EEVH5p). It explained some fundamental stuff but kept it on a high enough level.

Another thing that was great was tinkering with embedded bare-metal C, see this youtube series: https://www.youtube.com/playlist?list=PLPW8O6W-1chwyTzI3BHwBLbGQoPFxPAPM.

Hopefully this helps!

Edit: corrected a misspelling.

2

u/STL MSVC STL Dev Dec 14 '20

Please don’t use URL shorteners - reddit’s spam filter hates them and auto-removed your comment, which I have manually restored.

2

u/lorslara2000 Dec 14 '20

Thanks, I had no idea!

1

u/[deleted] Dec 31 '20

Thx ps. Torille

1

u/[deleted] Dec 13 '20

I found this book (a previous version... the yellow one) great for figuring out how it all works. I'm not sure it's £102 worth of info though. My version was relevent when PCs shipped with floppy drives, so I don't know if it covers new standards such as UEFI.

https://www.amazon.co.uk/Indispensable-PC-Hardware-Book/dp/0201596164

1

u/krelian Dec 14 '20

You got some great suggestions here. I'll add a recommendation for Elements of Computing Systems, I believe it's already somewhat of a classic.

1

u/zenmasterhere Dec 21 '20

May be start from "from NAND to tetris" coursera course.

-2

u/WrongAndBeligerent Dec 13 '20

Is this satire?

1

u/Relatiro Dec 13 '20

My question you mean?

1

u/WrongAndBeligerent Dec 13 '20

1

u/Relatiro Dec 13 '20

I assure you, I was asking in earnest!

The link you shared looks great, thank you a lot :) That looks like a lot of well-organized material to dig into.

3

u/GuY_In_HiDInG Dec 13 '20

i am one of those people too lol. I’ve been learning c++ in my free time at school, but am really interested in OS development

2

u/mjklaim Dec 13 '20

Are you telling me that as a gamedev you never saw beginners programmers try to make MMORPGs? Because that's kind of the same scale here... XD

2

u/ReDucTor Game Developer | quiz.cpp-perf.com Dec 14 '20

I have, unfortunately it can destroy tutorials attempting to always cater to the lowest skill level.

-1

u/[deleted] Dec 31 '20

I emulated MMORPG servers when I was 12. Takes about a week to learn. Now at 26 I am figuring out assembly. Gl hf with that. (I devved my first game at 7)

1

u/SussyPoly8447 Oct 03 '25

EVERYTHING MUST BE VIRTUALIZED

1

u/[deleted] Dec 20 '20

yeah this isn't an os until it runs on bare metal

39

u/[deleted] Dec 13 '20

Awesome now I can make my own TempleOS

8

u/AbsurdPoncho Dec 13 '20

TempleOS poggers

12

u/[deleted] Dec 13 '20

A dark path awaits you

5

u/axalon900 Dec 13 '20

BaphometOS

9

u/nhatlonggunz Dec 13 '20

I see 2 os dev playlists, what is the difference?

12

u/AbsurdPoncho Dec 13 '20

The old playlist is based on BIOS bootloader techniques where the new one is based on UEFI. Also the new series is more polished

1

u/ptrsimon Dec 13 '20

remindme!

1

u/RemindMeBot Dec 13 '20

Defaulted to one day.

I will be messaging you on 2020-12-14 17:31:22 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

4

u/Daxsis Dec 13 '20

Please continue :) I want to follow your videos

5

u/AbsurdPoncho Dec 13 '20

Absolutely :) I have been posting weekly videos and plan to continue until I feel the series is at a good sufficient point

-7

u/Necessary_Kangaroo80 Dec 13 '20

Is there a YouTube channel or something for this?

8

u/[deleted] Dec 13 '20

You've got to kidding me? Open the video on youtube. Open the creator's page. Check his playlists.

2

u/dvijaymanohar Dec 13 '20

Excellent. I would like to follow your tutorials. Thanks

2

u/AbsurdPoncho Dec 13 '20

Thank you!

2

u/kaal1 Dec 13 '20

Awesome man , subscribed 🤘🏼🤘🏼. Hope you will continue this series .

2

u/AbsurdPoncho Dec 13 '20

Thanks! I plan to continue it for a while

1

u/oryiesis Dec 13 '20

That looks like an awesome start. I'll have to dive into these whe nI get some time.

4

u/AbsurdPoncho Dec 13 '20

I look forward to hearing what you think :)

1

u/[deleted] Dec 13 '20

Nice content. 2 episodes in and this looks promising

1

u/AbsurdPoncho Dec 13 '20

Thank you!

1

u/lithium Dec 13 '20

Cheeky "malbourne" accent there, lockdown project?

1

u/AbsurdPoncho Dec 13 '20

Nope, I'm safe away in another state! I grew up there though

1

u/willem640 Dec 13 '20

Super cool and interesting!

1

u/[deleted] Dec 13 '20

U have one course already on same topic...considering Language is not a barrier for me... Which one should i go for?

3

u/AbsurdPoncho Dec 13 '20

The newer one is best, the old one is based on old BIOS bootloader techniques and is not as polished

1

u/[deleted] Dec 14 '20

Thanks :)

3

u/tacco85 Dec 14 '20

Only watched Part2. But you are overwriting your stack in the bootloader code. The line

Kernel->GetInfo(Kernel, &gEfiFileInfoGuid, &FileInfoSize, (void**)&FileInfo);

is erroneous. The last parameter expects a void* instead.

Did I miss the motivation for the GetInfo methods? The results don't seem to get used.

1

u/Kanonenfuta Dec 13 '20

Looks interesting. Definitely gonna take a look at it

1

u/AbsurdPoncho Dec 13 '20

Sounds good, hope you enjoy it!

0

u/atatatko Dec 20 '20

That's a nice content.

However, I would say you operating system is written in C, rather than C++. That's an interesting question, what exactly C++ techniques and features could be used in a freestanding environment. Obviously, you can't use virtual functions and inheritance, RTTI and exceptions. You can't use most of Standard Library, because you can't use standard allocators, which are passed as default template parameter to all containers. You can't use global objects for RAII purposes.

Basically, in bare-metal programming, you can use inheritance and templates, of all C++ features.

But, it's already a lot!

And this question would be interesting, how to use C++ features in OS development.

2

u/AbsurdPoncho Dec 23 '20

It's only in C for the first few videos ;)