久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

是否可以用 Java 編寫設備驅動程序?

Is it possible to code a device driver in Java?(是否可以用 Java 編寫設備驅動程序?)
本文介紹了是否可以用 Java 編寫設備驅動程序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我聽說過一些關于用 Java 編寫設備驅動程序的消息(聽說是用我的耳朵"而不是從互聯網上聽到的)并且想知道......我一直認為設備驅動程序是在操作系統級別上運行的,因此必須用與操作系統相同的語言(因此主要是 CI 假設)

I heard something about writing device drivers in Java (heard as in "with my ears", not from the internet) and was wondering... I always thought device drivers operated on an operating system level and thus must be written in the same language as the OS (thus mostly C I suppose)

  1. 我一般是錯的嗎假設?(好像是這樣)
  2. 外星人"中的司機如何操作系統中使用的語言?
  3. 有什么要求(來自編程語言的觀點)無論如何都需要設備驅動程序?

感謝閱讀

推薦答案

有幾種方法可以做到這一點.

There are a couple of ways this can be done.

首先,在操作系統級別"運行的代碼不需要使用與操作系統相同的語言編寫.它只需要能夠與操作系統代碼鏈接在一起.幾乎所有語言都可以與 C 互操作,而這正是我們所需要的.

First, code running at "OS level" does not need to be written in the same language as the OS. It merely has to be able to be linked together with OS code. Virtually all languages can interoperate with C, which is really all that's needed.

所以語言方面,技術上沒有問題.Java函數可以調用C函數,C函數可以調用Java函數.如果操作系統不是用 C 編寫的(比如說,為了論證它是用 C++ 編寫的),那么操作系統 C++ 代碼可以調用一些中間 C 代碼,這些代碼會轉發給你的 Java,反之亦然.C 幾乎是編程的一種通用語言.

So language-wise, there is technically no problem. Java functions can call C functions, and C functions can call Java functions. And if the OS isn't written in C (let's say, for the sake of argument that it's written in C++), then the OS C++ code can call into some intermediate C code, which forwards to your Java, and vice versa. C is pretty much a lingua franca of programming.

程序一旦被編譯(編譯為本機代碼),其源語言就不再相關.無論源代碼在編譯之前是用哪種語言編寫的,匯編程序看起來都差不多.只要你使用與操作系統相同的調用約定,就沒有問題.

Once a program has been compiled (to native code), its source language is no longer relevant. Assembler looks much the same regardless of which language the source code was written in before compilation. As long as you use the same calling convention as the OS, it's no problem.

更大的問題是運行時支持.操作系統中沒有很多軟件服務可用.例如,通常沒有 Java 虛擬機.(從技術上講,沒有理由不存在,但通常,但通常可以安全地假設它不存在).

A bigger problem is runtime support. Not a lot of software services are available in the OS. There usually is no Java virtual machine, for example. (There is no reason why there technically couldn't be, but usually, but usually, it's safe to assume that it's not present).

不幸的是,在其默認"表示中,作為 Java 字節碼,Java 程序需要很多基礎設施.它需要Java VM來解釋和JIT字節碼,它需要類庫等等.

Unfortunately, in its "default" representation, as Java bytecode, a Java program requires a lot of infrastructure. It needs the Java VM to interpret and JIT the bytecode, and it needs the class library and so on.

但是有兩種方法可以解決這個問題:

But there are two ways around this:

  • 在內核中支持 Java.這將是一個不尋常的步驟,但可以做到.
  • 或者將您的 Java 源代碼編譯為本機格式.Java 程序不必編譯為 Java 字節碼.您可以將其編譯為 x86 匯編程序.這同樣適用于您使用的任何類庫.這些也可以一直編譯到匯編程序.當然,部分 Java 類庫需要某些不可用的操作系統功能,但可以避免使用這些類.

所以是的,這是可以做到的.但這并不簡單,也不清楚你會得到什么.

So yes, it can be done. But it's not straightforward, and it's unclear what you'd gain.

當然,另一個問題可能是 Java 不允許您訪問任意內存位置,這會使很多硬件通信變得非常棘手.但這也可以解決,也許可以通過調用非常簡單的 C 函數來簡單地將相關的內存區域作為數組返回,供 Java 處理.

Of course another problem may be that Java won't let you access arbitrary memory locations, which would make a lot of hardware communication pretty tricky. But that could be worked around too, perhaps by calling into very simple C functions which simply return the relevant memory areas as arrays for Java to work on.

這篇關于是否可以用 Java 編寫設備驅動程序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 中文字幕一区二区三区乱码在线 | 日本三级全黄三级三级三级口周 | 国产精品美女久久久久 | 日日噜噜噜夜夜爽爽狠狠视频, | 亚洲一区二区三区视频 | 日韩免费高清视频 | 欧美精品一区二区免费 | 亚洲精品粉嫩美女一区 | 国产伦精品一区二区三区四区视频 | 欧美一区精品 | 久久久久成人精品 | 夜操| 在线欧美日韩 | 91视频18| 中文字幕日本一区二区 | 日韩欧美一区二区三区免费看 | 夜夜操操操| 性色在线 | 精品欧美一区免费观看α√ | 天天插天天操 | 亚洲欧美一区二区三区情侣bbw | 久久精品国产免费 | 日本久久网 | 一区二区三区观看视频 | 国产精品日韩欧美一区二区三区 | 在线免费观看成年人视频 | 日本精品视频在线 | 欧美一区二区三区久久精品 | 亚洲欧美一区二区三区国产精品 | 欧美性极品xxxx做受 | 亚洲国产成人久久久 | www国产亚洲精品久久网站 | 亚洲精彩免费视频 | 东京久久| 99re6在线视频精品免费 | 福利av在线| 国产欧美久久一区二区三区 | 久久精品久久久 | 久久精品免费一区二区 | 色视频在线观看 | 最新超碰 |