cpu intesive jave program

P

puzzlecracker

Is there a java library or "anything" I can use to increment CPU (used
percent) in a controlled matter? For example, I want to write a program
that can increase cpu by 25%. It is probably platform specific.

Any suggestions would be appreciated.

Thanks.
 
A

Alun Harford

puzzlecracker said:
Is there a java library or "anything" I can use to increment CPU (used
percent) in a controlled matter? For example, I want to write a program
that can increase cpu by 25%. It is probably platform specific.

Any suggestions would be appreciated.

You need to be running in kernel mode on most systems. While, in theory,
there's nothing to stop you putting a JVM in your kernel, it's never been
done (it would be *horrible*, but it would be worth doing for comedy value).

Basically, you need some way of hooking into the scheduler, or know exactly
what the other processes on the system are doing.

Alun Harford
 
P

puzzlecracker

Basically, you need some way of hooking into the scheduler, or know exactly
what the other processes on the system are doing.

do i really need know what other processes are doing? Let's say I am
not concerned with current percentage, but only with a value I want it
to boost to.

ex. currently cpu%=50
I want to to raise it by 20%, and that is fine if some other processes
raise it by some value n during interupts....

All I care is to know that my call can raise it if there is a room.
That is all.
 
J

Jon Martin Solaas

puzzlecracker said:
do i really need know what other processes are doing? Let's say I am
not concerned with current percentage, but only with a value I want it
to boost to.

ex. currently cpu%=50
I want to to raise it by 20%, and that is fine if some other processes
raise it by some value n during interupts....

All I care is to know that my call can raise it if there is a room.
That is all.

What exactly are you after? Boosting the jvm process scheduler priority?
You can use System.execute to run the renice command, but this won't
set a fixed cpu utilization, if the process is given low priority it'll
still consume 100% cpu if there aren't other processes in need of
cpu-cycles. Likewise, your process may be slowed down if it's
io-intensive, and won't be able to consume all cpu-cycles available.

Maybe you should look into a platform with realtime features, like
RT-Linux. And if you describe exactly what you need to do I'm sure
someone will be able to come up with much better answers than this :)
 
A

Alun Harford

puzzlecracker said:
do i really need know what other processes are doing? Let's say I am
not concerned with current percentage, but only with a value I want it
to boost to.

That's not the problem. The problem is that the scheduler can choose whether
or not to give you the CPU. The operating system controls the CPU, and can
simply not choose to run your code (too low priority, for example), so the
system won't get the load you want. If you're running in kernel mode you can
prevent yourself from being pre-empted.

Alun Harford
 
P

puzzlecracker

Alun said:
That's not the problem. The problem is that the scheduler can choose whether
or not to give you the CPU. The operating system controls the CPU, and can
simply not choose to run your code (too low priority, for example), so the
system won't get the load you want. If you're running in kernel mode you can
prevent yourself from being pre-empted.

Alun Harford

fine, cpu aside. Let me solve a simpler problem: in increase vm memory
heap in controlled fashion,
THanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top