用 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:16:04  来源:igfitidea点击:

Writing an operating system in C++

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

Also to add, This bookby Tanenbaum, where he explains the implementation details of minix.

另外要补充的是,Tanenbaum 的这本书,他解释了 minix 的实现细节。

回答by Greg Hewgill

You may consider looking at MINIXwhich is a small operating system for x86 systems. It was originally designed as a teaching project and has evolved into something that's intended to be useful in the real world.

您可以考虑查看MINIX,它是用于 x86 系统的小型操作系统。它最初是作为一个教学项目而设计的,现已发展成为旨在在现实世界中有用的东西。

回答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

I am not familiar with details, but by my knowledge BeOSwas written in C++. Sources should be freeley available as well as the documentation.

我不熟悉细节,但据我所知,BeOS是用 C++ 编写的。来源和文档应该是免费的。

回答by Max Lybbert

For a C++ operating system, you may want to look at NewOSor UnixLite.

对于 C++ 操作系统,您可能需要查看NewOSUnixLite

回答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 微内核也有点先进。