A
alexandre_paterson
Hi,
I decided (curiosity killed the cat) to do some testing
with the "CPU affinity" on my Linux system.
I read this (old, from 2003) article and compiled the
program they provide:
http://www.linuxjournal.com/article/6799
(the article explains how to use CPU affinity under
Linux and also gives some scenarios--there are
many others-- about *why* you would want to do
such a thing).
I then created a busy-looping ("single-threaded")
bash script and ran it. Sure enough my system
monitor (gkrellm) showed one of my two cores
being 100% used.
Then I could simply do :
..../alex # cpubind 13264 1
pid 13264's old affinity: 00000003 (bitmask, 3 means core 0 and
core 1)
pid 13264's new affinity: 00000001
and "cpubind 13264 2" and I could
see the busy-looping task consuming
100% of one core "jumping" from one core
to the other (and then staying on the
assigned core).
So CPU affinity is working, this is exactly
the result I wanted to see.
However I couldn't make it work for a Java
process and all its threads.
Did anyone here ever got CPU affinity to
work with Java on a Linux system and
if yes, how?
Does CPU affinity work under Windows
for a Java application? (task manager/
process/right-click on a Java process/
"set affinity")
(I've got no "real" multi-cores/multi-cpus Windows
machine in here, only VMWare ones).
For anyone running (native) Windows on
a multi-core machine, a simple:
while ( Math.abs(42) > 0 ) {}
does the trick to max one CPU.
(I know, I know, "while ( true ) {}" could do,
but my IDE would complain about my bad
coding practices
Any infos on this appreciated as always,
Alex
I decided (curiosity killed the cat) to do some testing
with the "CPU affinity" on my Linux system.
I read this (old, from 2003) article and compiled the
program they provide:
http://www.linuxjournal.com/article/6799
(the article explains how to use CPU affinity under
Linux and also gives some scenarios--there are
many others-- about *why* you would want to do
such a thing).
I then created a busy-looping ("single-threaded")
bash script and ran it. Sure enough my system
monitor (gkrellm) showed one of my two cores
being 100% used.
Then I could simply do :
..../alex # cpubind 13264 1
pid 13264's old affinity: 00000003 (bitmask, 3 means core 0 and
core 1)
pid 13264's new affinity: 00000001
and "cpubind 13264 2" and I could
see the busy-looping task consuming
100% of one core "jumping" from one core
to the other (and then staying on the
assigned core).
So CPU affinity is working, this is exactly
the result I wanted to see.
However I couldn't make it work for a Java
process and all its threads.
Did anyone here ever got CPU affinity to
work with Java on a Linux system and
if yes, how?
Does CPU affinity work under Windows
for a Java application? (task manager/
process/right-click on a Java process/
"set affinity")
(I've got no "real" multi-cores/multi-cpus Windows
machine in here, only VMWare ones).
For anyone running (native) Windows on
a multi-core machine, a simple:
while ( Math.abs(42) > 0 ) {}
does the trick to max one CPU.
(I know, I know, "while ( true ) {}" could do,
but my IDE would complain about my bad
coding practices
Any infos on this appreciated as always,
Alex