用 Java 或 C 编程的操作系统(内核)

发布于 2024-10-16 15:07:10 字数 178 浏览 8 评论 0原文

我要开始构建操作系统,但我不知道为内核选择哪种编程语言。我最喜欢的语言是Java,但我知道所有主要操作系统(Windows、Linux、Mac OS)都是用C编程的,而且Java需要虚拟机。与基于 Java 的操作系统相比,基于 C 的操作系统是否更难编程?这些语言各自的优点和缺点是什么?

I'm going to start building operating system and I don't know which programming language to choose for kernel. My favorite language is Java but I know that all major operating systems (Windows, Linux, Mac OS) is programmed in C, moreover Java requires virtual machine. Does it would be much harder to program than Java-based OS than C-based OS? What are the advantages and disadvantages of each of these languages?

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

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

发布评论

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

评论(6

紫轩蝶泪 2024-10-23 15:07:11

基于 Java 的操作系统比基于 C 的操作系统更难编程吗?

您将如何编写硬件级编程来处理 Java 中的中断?

Does it would be much harder to program than Java-based OS than C-based OS?

How would you write the hardware-level programming to handle interrupts in Java?

陌伤ぢ 2024-10-23 15:07:11

似乎已经有几种基于 Java 的操作系统了。我对操作系统编程了解不多,但似乎有相当广泛的文献(尽管很多是德语的)关于基于 Java 的操作系统 JX,来自埃尔兰根大学:http://www4.informatik.uni-erlangen.de/Projects/JX/publications.html< /a>
也许有什么可以帮忙的。

不过,编写基于 C 的操作系统应该是最简单的,因为有关它的信息太多了。

There seem to be several Java-based OSs already out there. I don't know a lot about OS-programming, but there seems to be quite an extensive literature (altough a lot of it in German) about a Java-based OS called JX, from the University of Erlangen: http://www4.informatik.uni-erlangen.de/Projects/JX/publications.html
Maybe there is something there to help.

Writing a C-based OS should be the easiest, though, simply due to there being so much more information about it.

奢华的一滴泪 2024-10-23 15:07:11

除非您能够使用将 Java 编译为机器语言的编译器,否则您将无法使用 Java 编写操作系统内核。 Java 需要一个解释字节码并执行本机指令(依赖于内核)的虚拟机。您必须能够直接与硬件交互才能对操作系统进行编程,而这是使用 Java 无法做到的。事实上,你唯一的选择就是 C 与汇编的混合。

You won't be able to program an OS kernel in Java unless you have access to a compiler that will compile Java into machine language. Java requires a virtual machine which interprets the byte code and executes native instructions (that rely on the kernel). You must be able to interact directly with the hardware in order to program an OS which is something you simply can't do with Java. Your only option, really, is C mixed with assembly.

メ斷腸人バ 2024-10-23 15:07:11

JVM 提供了大量类似操作系统的功能,并且无法用 Java 编写——因此无论哪种方式,您最终都会用 C(或可以生成代码的东西)编写大量代码不需要虚拟机)。

The JVM provides an awful lot of OS-like capabilities, and it can't be written in Java -- so either way, you're going to end up writing an awful lot of the code in C (or something that can produce code that doesn't require a virtual machine).

想你只要分分秒秒 2024-10-23 15:07:10

http://wiki.osdev.org 是一个在这方面非常有用的网站。它告诉您如何构建工具链、可用的语言选项,并且有一些很棒的示例代码。

伊万

http://wiki.osdev.org is an extremely useful site on that matter. It tells you how to build your toolchains, which language options that are available, and has some great example code.

Yvan

甜嗑 2024-10-23 15:07:10

我谦虚地建议你在尝试构建操作系统之前真正学习一门编程语言,之后你就会意识到你可以或不能用哪些语言自己编写内核。

像 Java 这样的编程语言根本不提供创建 os 所需的低级例程。您可以用 c 或 c++ 实现您的操作系统。除非您掌握引导代码(阅读汇编程序)和 C 等编程语言,否则最好重新考虑一项可能更简单的任务。

但是,您可以通过将一个操作系统作为另一个操作系统中的程序运行来模拟该操作系统,在这种情况下,您可以尝试使用您选择的任何语言。

I would humbly suggest that you truly learn a programming language before trying to build an operating system, after which you would realize in which languages you can or cannot write kernels in yourself.

Programming languages such as Java simply does not offer the low-level routines necessary to create an os. You can implement your OS in c or c++. Unless you master bootstrapping code (read assembler) and a programming language such as c, it would be a good idea to reconsider a perhaps easier task.

You could however emulate an OS by running it as a program in another OS, in which case you may experiment with any language of your choise.

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