用 C++ 编写操作系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2145501/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Writing an operating system in C++
提问by dileepa
what is a way to create a my own operating system using c++. I have been created boot loader (using nasm,qemu) but I haven't knowledge to add an kernel to this boot loader.
什么是使用 C++ 创建我自己的操作系统的方法。我已经创建了引导加载程序(使用 nasm、qemu),但我不知道向这个引导加载程序添加内核。
回答by Kornel Kisielewicz
Here's a ton of informationthat you'll eventually need, the dreaded OS programming FAQ.
这是您最终需要的大量信息,即可怕的操作系统编程常见问题解答。
回答by Potatoswatter
Be careful, C++ is pretty heavyweight for an OS kernel.
小心,C++ 对于操作系统内核来说是相当重量级的。
- There are services like exceptions that you'll have to support with a runtime library.
- It won't feel like C++ until you add a heap.
- Kernels are very sensitive to where objects are allocated; the one-heap model usually used in C++ isn't really suitable.
- Coupling APIs to data structures is a bad idea. BeOS had problems with this. You need to hide the size of your internal structures from users, and that means jumping through hoops (Pimpl, private constructor, virtual functions) when APIs are member functions.
- 您必须使用运行时库支持诸如异常之类的服务。
- 除非你添加一个堆,否则它不会像 C++。
- 内核对对象的分配位置非常敏感;通常在 C++ 中使用的单堆模型并不是很合适。
- 将 API 耦合到数据结构是一个坏主意。BeOS 在这方面有问题。您需要对用户隐藏内部结构的大小,这意味着当 API 是成员函数时,需要跳过一些障碍(Pimpl、私有构造函数、虚函数)。
It sounds like you're already further along than most, so keep asking questions and you'll probably end up somewhere nice! :vD
听起来你已经比大多数人走得更远了,所以继续提问,你可能会在一个不错的地方结束!:vD
回答by sud03r
回答by Greg Hewgill
回答by Alex
you can take a look at minix 3 source code. it's a very simple os, created with the purpose of understand how operating system works.
您可以查看 minix 3 源代码。这是一个非常简单的操作系统,旨在了解操作系统的工作原理。
you can also study all the tanenbaum book about os. they are all very complete and I remember that one book has the complete source of minix attached and commented
您还可以学习有关 os 的所有 tanenbaum 书籍。它们都非常完整,我记得有一本书附上了 minix 的完整来源并进行了评论
回答by RED SOFT ADAIR
回答by Vijay Mathew
回答by Max Lybbert
回答by Audrius Meskauskas
A usable operating system can be developed on the top of L4, even by a single student in one semester along with other courses (but with all driver issues already resolved). If found this being a great adventure, and the L4 microkernel is also kind of advanced.
一个可用的操作系统可以在L4的顶部开发,即使是一个学期的单个学生也可以与其他课程一起开发(但所有驱动程序问题都已经解决)。如果发现这是一次伟大的冒险,L4 微内核也有点先进。