Hi everybody. I am working on a profiling agent. Among other things it analyzes the active threads' status. To be successful it has to match thread names to IDs. Here is a problem though: When I run a simple test case that creates several threads and sets a name for each one, I get ThreadNameChanged notifications fired before ThreadCreated. Below is WinDbg output from breakpoints set for the appropriate events:
ModLoad: 000007fe`e57f0000 000007fe`e5aa4000 C:\vlh\Builds\X64\My\OciVOB\DevInstall_debug\X64\Purify.rsc
ThreadCreated 9021472
ThreadCreated 9130704
ModLoad: 000007fe`de930000 000007fe`dee1a000 mscorlib.dll
ModLoad: 00000000`04c70000 00000000`0515a000 mscorlib.dll
ModLoad: 000007fe`fb7b0000 000007fe`fb7bc000 C:\Windows\system32\VERSION.dll
ModLoad: 000007fe`de930000 000007fe`dee1a000 C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
ModLoad: 000007fe`eb990000 000007fe`ebac1000 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clrjit.dll
ThreadNameChanged 86305504 Test_0
ThreadNameChanged 86386128 Test_1
ThreadNameChanged 86389968 Test_2
ThreadNameChanged 86393808 Test_3
ThreadNameChanged 86397648 Test_4
ThreadNameChanged 86358608 Test_5
ThreadNameChanged 86361872 Test_6
ThreadNameChanged 86365136 Test_7
ThreadNameChanged 86368976 Test_8
ThreadNameChanged 86372816 Test_9
ThreadCreated 86305504
ThreadCreated 86386128
ThreadCreated 86389968
ThreadCreated 86393808
ThreadCreated 86397648
ThreadCreated 86358608
ThreadCreated 86361872
ThreadCreated 86365136
ThreadCreated 86368976
ThreadCreated 86372816
The problem is: I register thread information on ThreadCreated event and then update it as other events come in, so out-of-sequence events throw the analysis off.
Of course I can map thread IDs to thread information blocks and re-sequence the incoming events. But common, doesn't this violate the whole "Cause and effect" premise?
Regards,
Victor