Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Hardware Interrupt Handling

I would like to know if it is possible to automatically invoke a Java method when a hardware interrupt is raised.

like image 307
Sigh..It's Urgent Avatar asked Dec 30 '22 10:12

Sigh..It's Urgent


1 Answers

There may be an alternative.

I'm doing something similar: In an application I monitor 4 mice for clicks. Those clicks generate interrupts but I'm happy enough not to deal with them directly from Java.

Under Linux, it turns out there are device files (/dev/input/mouse#) that spew a bunch of characters when something happens with the mouse. I have a Thread for each one with a FileReader blocking on a read. Once characters arrive, the appertaining thread unblocks and I can do whatever processing I like.

So the idea is: If possible, find a way to get a device driver to make the data accessible to you in file/device form, then you can access it from Java using just IO calls from the Java library, with no weird bit-twiddling code and C required in between.

like image 94
Carl Smotricz Avatar answered Jan 11 '23 23:01

Carl Smotricz