开发x86架构的操作系统

发布于 2024-07-05 17:19:06 字数 1453 浏览 13 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

行至春深 2024-07-12 17:19:06

您选择什么语言并不重要。 如果该语言是图灵完备的,那么您可以用它编写操作系统。

然而,语言的表达能力将使某些类型的设计非常容易或非常难以实现。 例如,旧的 Smalltalk 操作系统的“活力”和活力取决于它们是在 Smalltalk 中实现的这一事实。 您也可以用C 语言做到这一点,但这可能太难了,您甚至不会考虑它。 JavaScript 或 Ruby OTOH 可能非常适合。

微软研究院的奇点是另一个例子。 除了 Sing#、Spec#C#(或类似语言),因为架构的大部分内容都依赖于这些语言的静态类型安全性和静态可验证性。

需要记住的一件事是:用 C 实现的操作系统的设计空间几乎已经被充分探索。 实际上有数千个。 然而,在其他语言中,您实际上可能会发现一些以前没有人发现过的东西! 用 Java 编写的操作系统大约只有十几个,用 C# 编写的操作系统大约有六种,用 Haskell 编写的操作系统大约有两个,用 Python 编写的操作系统只有一个,而用 Python 编写的操作系统没有 Ruby 或 JavaScript。

尝试用 Erlang 或 Io 编写操作系统,看看这如何影响您对操作系统的思考!

It doesn't really matter, what language you choose. If the language is Turing-complete, then you can write an OS in it.

However, the expressiveness of the language will make certain kinds of designs very easy or very hard to implement. For example, the "liveliness" and dynamism of the old Smalltalk OSs depends on the fact that they are implemented in Smalltalk. You could do that in C, too, but it would probably be so hard that you wouldn't even think about it. JavaScript or Ruby OTOH would probably be a great fit.

Microsoft Research's Singularity is another example. It simply couldn't be implemented in anything other than Sing#, Spec# and C# (or similar languages), because so much of the architecture is dependent on the static type safety and static verifiability of those languages.

One thing to keep in mind: the design space for OSs implemented in C is pretty much fully explored. There's literally thousands of them. In other languages, however, you might actually discover something that nobody has discovered before! There's only about a dozen or so OSs written in Java, about half a dozen in C#, something on the order of two OSs in Haskell, only one in Python and none in Ruby or JavaScript.

Try writing an OS in Erlang or Io, and see how that influences your thinking about Operating Systems!

护你周全 2024-07-12 17:19:06

在我最后一年的拼贴项目中,我开发了一个小型 x86 操作系统,带有虚拟内存管理器、虚拟文件系统和完全抢占式多任务处理。 我将其开源,代码被大量注释,请查看其源代码伪造页面:

https://github.com /stephenfewer/NoNameOS

根据我的经验,我可以推荐以下内容:

您将需要 x86 汇编语言来完成各个部分,这是不可避免的,但可以保持在最低限度。 您很快就会开始运行 C 代码,这是操作系统开发的经过验证的选择。 一旦您拥有某种可用的内存管理器,如果您愿意,您就可以进入 C++(您需要某种内存管理器来执行 new 和删除之类的操作)。

无论您选择哪种语言,您仍然需要汇编和编译。 C 使系统从引导状态进入 BIOS 使您进入任何可用状态的状态。

最终,您选择的主要语言将取决于您想要开发的操作系统类型。

我的开发环境是 GNU 开发工具 DJGPP 的 Windows 端口以及 NASM 汇编器。 对于我的 IDE,我使用了 IBM 的 Eclipse 和 CDT 插件,在 Eclipse 中提供 C/C++ 开发环境。

对于测试,我推荐 BOCHS,一个开源 x86 PC 模拟器。 它可以让您快速启动操作系统,这非常适合测试,并且可以集成到 eclipse 中,这样您只需按一下按钮即可构建和运行操作系统。 我还建议偶尔使用 VMWare 和物理 PC,因为这样您就可以发现一些细微的错误。

PS 操作系统的开发确实很有趣,但也非常密集,我的花了 12 个月的大部分时间。 我的建议是做好计划,您的设计是关键! 享受 :)

For my final year project in collage I developed a small x86 OS with a virtual memory manager, a virtual file system and fully preemptive multitasking. I made it open source and the code is heavily commented, check out its source forge page at:

https://github.com/stephenfewer/NoNameOS

From my experience I can recommend the following:

You will need x86 assembly language for various parts, this in unavoidable, but can be kept to a minimum. Fairly quickly you will get running C code, which is a proven choice for OS development. Once you have some sort of memory manager available you can go into C++ if you like (you need some kind of memory manager for things like new and delete).

No matter what language you choose you will still need assembly & C to bring a system from boot where the BIOS leaves you into any useable form.

Ultimately, the primary language you choose will depend on the type of OS you want to develop.

My development environment was the Windows port of the GNU development tools DJGPP along with the NASM assembler. For my IDE I used IBM's Eclipse with the CDT plugin which provides a C/C++ development environment within Eclipse.

For testing I recommend BOCHS, an open source x86 PC emulator. It lets you boot up your OS quickly which is great for testing and can be integrated into eclipse so you can build and run your OS at the push of a button. I would also recommend using both VMWare and a physical PC occasionally as you can pick up on some subtle bugs that way.

P.S. OS development is really fun but is very intensive, mine took the best part of 12 months. My advice is to plan well and your design is key! enjoy :)

沐歌 2024-07-12 17:19:06

马里兰大学提供了一门使用 GeekOS 的操作系统课程。 这是一个小型的、经过广泛评论的操作系统,专为教育目的而设计,可以使用 Bochs 或 QEMU 模拟器运行。

有关如何在课程中使用它的示例,请查看该课程之前提供的课程 网页。 在那里,您会找到必须向 GeekOS 添加不同功能的作业。

这是熟悉在 x86 架构上运行的小而简单的操作系统的好方法。

There is an OS course offered at the University of Maryland that utilizes GeekOS. This is a small, extensively commented OS designed for educational purposes which can be run using the Bochs or QEMU emulators.

For an example of how it is used in a course, check out a previous offering of the course at the class webpage. There, you will find assignments where you have to add different functionality to GeekOS.

Its a great way to get familiar with a small and simple OS that runs on the x86 architecture.

梦与时光遇 2024-07-12 17:19:06

语言和编译器完全取决于您想要完成的任务。 不过,我建议您可能从太低的层面来解决这个问题。

有一些关于操作系统基础知识的材料。 麻省理工学院有关于该主题的开放课件。 通读 Andrew Tannenbaum操作系统系列,并查看 Minix 等内容>。

了解那里有什么。 开始修补一些东西。 借鉴想法,看看它们的去向。 如果你真的愿意,你可以重新发明轮子,但你会通过借鉴他人的作品学到更多东西。

Language and compiler depend entirely on what you're attempting to accomplish. I would suggest, though, that you might be approaching the problem from too low a level.

There are materials out there on operating system fundamentals. MIT has OpenCourseware on the subject. Read through Andrew Tannenbaum's Operating Systems series, and look at things like Minix.

Get an idea for what's out there. Start tinkering with things. Borrow ideas, and see where they go. You can reinvent the wheel if you really want, but you'll learn more by building on the works of others.

醉梦枕江山 2024-07-12 17:19:06

请务必查看我的问题的答案:

如何开始操作系统开发

Be sure to check out the answers to my question:

How to get started in operating system development

固执像三岁 2024-07-12 17:19:06

我曾经对 386SX 做过一次,它位于 PCI 板上。 关于如何在保护模式下启动 X86 cpu 的一个很好的资料是 linux 的源代码。 这只是一些汇编语句。 之后你可以使用 gcc 编译你的 C 代码。 结果是 ELF 格式的目标代码。 我编写了自己的链接器,用目标代码编写程序。 是的,它成功了! 祝你好运。

I've done that once for a 386SX, which was on a PCI board. A good source on how to start a X86 cpu in protected mode is the source code of linux. It's just a few assembly statements. After that you can use gcc to compile your C code. The result is objectcode in ELF format. I wrote my own linker, to make a program out of the objectcode. And yes, it worked! Good luck.

蓝海似她心 2024-07-12 17:19:06

使用 ANSI C,并从模拟器开始。
当你移植到真机上时,会有一些汇编代码。 上下文切换和中断处理(例如)更容易用汇编语言编写。

Andy Tannenbaum 写了一本关于操作系统的好书。 还存在许多其他好的东西。

祝你好运! 没有什么比编写自己的操作系统更好的了,无论多么小。

Use ANSI C, and start off with an emulator.
When you port over to a real machine, there will be some assembler code. Context switching and interrupt handling (for instance) is easier to write in assembler.

Andy Tannenbaum has written a good book on OS. Many other good ones exist.

Good luck! There is nothing quite like haveing written your own OS, however small.

等数载,海棠开 2024-07-12 17:19:06

另请查看 OSDev.org,其中包含您入门所需的所有信息。

Also check out the OSDev.org which have all information you need to get started.

深陷 2024-07-12 17:19:06

您可能想查找XINU。 它是一个小型的 x86 操作系统,除了供学生剖析之外,没有真正用于任何其他用途。

You might want to look up XINU. it's a tiny OS for x86 that isn't really used for anything other than to be dissected by students.

偏爱你一生 2024-07-12 17:19:06

毫无疑问,我会使用艾达。 这是我遇到过的最好的通用系统编程语言,没有之一。 例如,Ada 在指定记录中对象的位布局方面比 C 好得多。Ada 还支持在特定内存位置上覆盖记录。 C 要求您使用指针来达到相同的效果。 这可行,但更容易出错。 Ada 还具有对中断的语言支持。

另一个:安全。 Ada 默认对数组分配进行边界检查,但允许您在需要时将其关闭。 C“默认”不对数组进行边界检查,因此您必须在需要时手动执行此操作。 时间证明这不是正确的默认设置。 你会忘记一个需要它的地方。 缓冲区溢出漏洞是黑客最常见的安全漏洞。 他们有完整的网站解释如何查找和使用它们。

至于学习如何做到这一点,我知道的两本书是 XINU (Unix 向后,与山达基无关),以及 Project Oberon。 第一个是在我的操作系统研究生课程中使用的,第二个是由 Pascal 的创建者 Nikalus Wirth 编写的。

Without a doubt, I'd use Ada. It's the best general-purpose systems-programming language I have come across, bar none. One example, Ada's much better for specifying bit layout of objects in a record than C. Ada also supports overlaying records on specific memory locations. C requires you to play with pointers to acheive the same effect. That works, but is more error-prone. Ada also has language support for interrupts.

Another: Safety. Ada defaults to bound checking array assignments, but allows you to turn it off when you need it. C "defaults" to no bound checking on arrays,so you have to do it yourself manually whenever you want it. Time has shown that this is not the right default. You will forget one where it is needed. Buffer overflow exploits are the single most common security flaw used by crackers. They have whole websites explainng how to find and use them.

As for learning about doing this, the two books I'm aware of are XINU (Unix backwards, nothing to do with Scientology), and Project Oberon. The first was used in my Operating Systems graduate course, and the second was written by Nikalus Wirth, creator of Pascal.

只是我以为 2024-07-12 17:19:06

如果你想编写一个操作系统,那么你需要几个人。 一个操作系统不能写一个人。 我认为最好是在现有的操作系​​统项目上工作

这只是操作系统项目的一小部分。 您如何看待每种可能的语言都有一个项目。

If you want write an OS then you need a couple of people. A OS can not write a single people. I think it is better to work on existing OS projects

This is only a short list of OS projects. How you can see there is a project for every possible language.

逆蝶 2024-07-12 17:19:06

如果您正在制作一个完整的操作系统,您将需要使用多种语言。 我至少期望汇编、C 和 C++。

我会使用虚拟机进行大部分测试。

If you are making a full OS, you will need to use a range of languages. I would expect Assembly, C and C++ at the very least.

I would use a Virtual Machine for most of the testing.

逐鹿 2024-07-12 17:19:06

C 最有可能...所有主要操作系统都是用 C/C++ 或 Objective-C(Apple)编写的

C most probably...all major OS-es have been written in C/C++ or Objective-C(Apple)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文