Closed plusterkopp closed 6 years ago
Thread.tid is an incrementing counter for the process starting at 1. Not to be confused with the thread id given to the thread by the OS. Typically OSes give thread IDs which are 16-bit however Linux for example can be tuned to allow more. It is possible the test isn't valid, it would need to be reviewed. ᐧ
On 27 March 2017 at 18:05, plusterkopp notifications@github.com wrote:
On this CentOS machine (2x18 cores, SMT), I get thread IDs like 121295. This fails when testGettid asserts tid < 2^16. What is the reason for that assumption? Thread#tid is defined as long and set from Thread.threadSeqNumber, which is long, too.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenHFT/Java-Thread-Affinity/issues/34, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBU8XVBXBbl28eHXtRU08uYTZaAOyCyks5rp-xTgaJpZM4MqjWX .
Actually, in PosixJNAAffinityTest we have
tid = Thread.currentThread().getId(); ... assertTrue(tid < 1 << 16);
with
public long getId() { return tid; }
in Thread and
tid = nextThreadID();
in Thread#init(...);
So, this is the Java Thread id, not the one that we get from the SYS_gettid
syscall and store in a ThreadLocal.
Where is threadSeqNumber
being initialized? Maybe it does not make sense to expect something of that value.
That test only makes sense if the getId() has been overwritten with the actual OS pid of the thread. ᐧ
On 28 March 2017 at 12:20, plusterkopp notifications@github.com wrote:
Actually, in PosixJNAAffinityTest we have tid = Thread.currentThread().getId(); ... assertTrue(tid < 1 << 16); with public long getId() { return tid; } in Thread and tid = nextThreadID(); in Thread#init(...); is there a native ID, too? Where? And where is threadSeqNumber being initialized?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OpenHFT/Java-Thread-Affinity/issues/34#issuecomment-289739179, or mute the thread https://github.com/notifications/unsubscribe-auth/ABBU8fCGzMaOushEQQe0hgrLw_QXbdS7ks5rqO0NgaJpZM4MqjWX .
On this CentOS machine (2x18 cores, SMT), I get thread IDs like 121295. This fails when testGettid asserts tid < 2^16. What is the reason for that assumption? Thread#tid is defined as long and set from Thread.threadSeqNumber, which is long, too.