0

I have a newbie question, so I started looking at Java Affinity library and I have the following code:

public static void main(String[] args){
    AffinityLock l = AffinityLock.acquireLock(5);
    Thread.currentThread().setName("Testing");
    System.out.println("\nThe assignment of CPUs is\n" + AffinityLock.dumpLocks());
    while(!Thread.currentThread().isInterrupted()){

    }
}

and I have output:

The assignment of CPUs is
0: General use CPU
1: Reserved for this application
2: Reserved for this application
3: Reserved for this application
4: Reserved for this application
5: Thread[Testing,5,main] alive=true
... 

But if I go ps -alF, I can see the process is not running on PSR 5. Am I missing something obvious?

Thanks a lot!! - Mag

Theboy
  • 353
  • 1
  • 2
  • 8

1 Answers1

0

A thread could be executed on different cores. Please read this fascinating discussion.

In this particular case you can stop the debugger in the method net.openhft.affinity.LockInventory.set(CpuLayout cpuLayout) and do some steps to find out what happens during initialization of logicalCoreLocks array.

It looks like the dumped data was actual only at the moment of initialization, but it's not when being printed to the console.

diziaq
  • 6,881
  • 16
  • 54
  • 96