问题描述
Linux-on-Java与C字节大小的PC架构硬件端口输入/输出功能等效吗?
What is the Java-on-Linux equivalent to the C byte-sized PC-architecture hardware port input/output functions?
对于输出,如下所示为outb
:
For output there is outb
as in this:
tmp = inb(0x61);
if (tmp != (tmp | 0x01))
outb(0x61, tmp | 0x01);
对于输入,请输入inb
,如下所示:
For input there is inb
as in this:
tmp = (inb(0x61) & 0xfe);
outb(0x61, tmp);
目的:我想实现一些比这更少的开销:
Purpose: I want to implement something that imposes less overhead than this:
try { Runtime.getRuntime().exec("beep") } catch (IOException e) {}
作为将代码7(钟形字符)发送到标准输出的一种替代方法,因为在Ubuntu中似乎已积极禁用了该代码.工具箱的提示音也静音.
as an alternative to sending code 7 (the bell char) to the standard output because that seems to have been aggressively disabled in Ubuntu. Toolkit's beep is also mute.
推荐答案
我认为您在拨错火车.
Java是一种编译为虚拟机体系结构的面向对象的高级语言.汇编器I/O指令特定于硬件处理器.两者之间没有直接对等的地方.
Java is a object-oriented high-level language compiling to a virtual machine architecture. Assembler I/O instructions are hardware processor specific. There is no direct equivalence between the two.
您最好的期望是将Java代码(使用管道,共享内存,套接字等)与执行所需I/O的本地Linux应用程序进行接口.
The best you could hope for is to interface your Java code (using pipes, shared memory, sockets, etc) with a native Linux app which performs the required I/O.
这篇关于在Linux上从Java访问PC硬件端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!