On Windows, you can call SetProcessAffinityMask for a process and SetThreadAffinityMask for a thread. However, Windows only appears to expose GetProcessAffinityMask and not a similar API for individual threads of a process.
I have a multi-threaded program that binds individual threads to processors at run-time. As I run it, I'd like to (externally) query which threads are running on which processors to make sure it's working correctly. I've written a small command-line utility to do this. But I can't seem to find a means of finding which processor(s) or core(s) an individual thread is bound to.
This apparently must be possible; I've seen descriptions online of the adplus debugging utility being able to show pstack-like output to show thread affinity. And Process Explorer shows a Threads tab on multi-processor machines that shows the "Ideal Processor" of a thread.
Does anyone know how to query this piece of information?