views:

226

answers:

4

I'd like to use of the Vista+ feature of I/O prioritization. Is there a platform independent way of setting I/O priority on an operation in Java (e.g. a library, in Java 7) or should I revert to a sleeping-filter or JNx solution? (Do other platforms have similar feature?)

+2  A: 

From a google search it does not seem that Java supports IO Prioritization yet.

Windows Vista does but I don't know anything about it. Is it per process or more fine-grained?

Linux since 2.6.13 supports ionice(1), which will set IO priority on a per process basis.

Sean A.O. Harney
Vista+ has it per I/O handle. I was hoping for some library to expose this functionality. Thank you for the Linux info.
kd304
+2  A: 

This is the kind of thing that is difficult for Java to support because it depends heavily on the capabilities of the underlying operating system. Java tries very hard to offer APIs that work the same across multiple platform. (It doesn't always succeed, but that's a different topic.)

In this case, a Java API would need to be implementable across multiple versions of Windows, multiple versions of Linux, Solaris, and various other third party platforms. Coming up with a platform independent model of IO prioritization that can be mapped to the functionality of the range of OS platforms would be hard.

For a now, I suggest that you look for a platform specific solution that goes outside of Java to make the necessary tuning adjustments; e.g. use Process et al to run an external command, or do the work in a wrapper script before starting your JVM.

Stephen C
Thank you. I will check your suggestions.
kd304
+3  A: 

If you really need to use this feature and you really want to do this in Java, you can always use Java JNI to hook the JVM into your own, custom c/c++ implementation of an I/O handler.

JNI allows you to write native (OS specific) code and call it from a Java application.

http://java.sun.com/docs/books/jni/

davidemm
Thanks, I knew that already. I wanted some more convenient way of doing it.
kd304
A: 

Placeholder for aggressive future code answer.

Chris Kaminski
You don't need to leave a placeholder - you can post an answer at any time.
bdonlan
(keep in mind if you're aiming for the abandoned-bounty auto-selection, you need to be voted to +2 or above to be eligible...)
bdonlan
It was to remind me to come back. I'm probably going to miss the bounty, but I've got a good start on some code he can use.
Chris Kaminski