CPU assignment in ProcessBuilder

S

Simon Chen

Hi all,

I am trying to use ProcessBuilder to create a child process in java.
However, I want to be able to lock that child process to a particular
CPU. Basically, that process only runs on a designated core, similar
to using sched_setaffinity() under C/C++. Is there a way of doing so?

Thanks a lot!
-Simon
 
A

Arne Vajhøj

Simon said:
I am trying to use ProcessBuilder to create a child process in java.
However, I want to be able to lock that child process to a particular
CPU. Basically, that process only runs on a designated core, similar
to using sched_setaffinity() under C/C++. Is there a way of doing so?

No. Only by using JNI and C.

Arne
 
R

Roedy Green

I am trying to use ProcessBuilder to create a child process in java.
However, I want to be able to lock that child process to a particular
CPU. Basically, that process only runs on a designated core, similar
to using sched_setaffinity() under C/C++. Is there a way of doing so?

This question came up a while back. The responses were of two
categories:

1. no you can't

2. why would you want to?
--
Roedy Green Canadian Mind Products
http://mindprod.com

There is a certain cosmic justice in the bankruptcy of General Motors. People at every level of the economic spectrum who for
economic motives helped GM pummel the environment with deliberately inefficient automobiles are being punished both severely and economically.
 
N

Nigel Wade

Simon said:
Hi all,

I am trying to use ProcessBuilder to create a child process in java.
However, I want to be able to lock that child process to a particular
CPU. Basically, that process only runs on a designated core, similar
to using sched_setaffinity() under C/C++. Is there a way of doing so?

My initial thought would be "not in Java". Java is platform independent and what
you are requesting is most definitely platform dependent.

Some OS allow you to define CPU affinity when the process is created, so you may
be able to do so by setting the correct environment, or command line, for the
Process. Or by creating a script to do what's necessary and running that.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top