Also is it possible for example JVM to use 2 cores on Quad core machine ?
What are you useing for a threading tool?
What operating system?
If OpenMP, you can seta restriction using environment variable
Or at compile tile
Or at run time
Also, on Windows and Linux you can restrict the number of cores available to a process (applicaiton).
(you will have to look that one up)
I want to do it for Operating system (Solaris/Linux/Windows etc) , to swtich off extra cores, so that my application typically sees less cores(Logical processors) to run its threads
The OMP_NUM_THREADS environment variable does this for OpenMP threaded programs. Other threading tools may use a different technique (i.e. read the documentation).
Most operating systems have the concept of Environment Variables (Windows/Solaris/Linux do). A process inherits the environment variables from which it is run. Typically a system has system wide environment variables and the user runs applications (processes) within a command shell (CMD on Windows) and this command shell starts with the environment variables of the environment in which it was spawned from, and subsequent to start, the command shell (copies of)environment variables can be added to, deleted, or changed.
On Windows, you can (stepse vary depending of version of Windows)perform:
Start | Control Pannel | System | Advanced | Environment Variables | User Variables | New
And in there add OMP_NUM_THREADS as variable name and 10 as value.
*** Then rember you did this *** when you next project doesn't use all 16 cores.
Alternately, you can create aBatch file (command script) toissue:
Then create a shortcut to the batch file and launch your application that way. Now the limitation only applies to the application launched by way of the shortcut.
Linux has similar techniques.
OpenMP is not an application. It is a threading model tool used to build applications.
IF (capitals to stress) your JVM is multi-threaded AND IF the multi-threaded code were compiled using OpenMP as threading tool THEN setting the OMP_NUM_THREADS=10 will fix the problem.
IF your JVM is NOT multi-threaded AND if you run a collection of JVMs AND if you want these collections of JVMs to run ONLY with a sub-set of cores THEN look at using process affinity to restrict each JVM to a subset of 10 cores on your system.
On Windows, run the TaskManager | Processes | Click on title tab "Image Name" to sort alphabetically | Right-click on 1st JVM and set the affinity mask to the cores you want. Repete for all JVMs.
On Windows, in the header of the applicaiton, there exists two bit masks. These contain affinity masks (one is preferred the other is required). Some time spent with Google will get you the information you need to set this mask.
On Linux, from a command line, you can issue (our use option) that in effect says "for all processes spawned from this shell, restrict it to this xxxx affinity mask"
Windows may have a similar thing (google is your friend).
The problem you are having in getting the information you want, is you are not specifying your circumstances to the extent necessary to inform the viewers of this forum with the information they need to provide you with the answer you want.
I've recently uploaded a video showing how to change the number of cores using Windows Vista affinity settings. You can do the same for JVM and you will restrict the number of cores. However, you have to take into account L2 and L3 cache issues.
This is the link to my video http://www.youtube.com/watch?v=-Jfg3IHBNS0
It includes a book promotion. However, you can stop it before the promotion :)