Today is the last day of the Spooktacular Challenge! If you’ve made it this far, you are a truly intrepid programmer. Either that, or you’ve been permanently deranged by the horrors of ETW, and you’re mindlessly opening your email and randomly happened to pick this one.
In case it happens to be the former rather than the latter, I have one last hint for you.
If you want to make your API work with multiple threads, such that a user can profile regions in more than one of their threads at the same time, you may find yourself needing to track several profiling regions in your collection loop — especially if you want to handle CSwitch events properly.
Today’s hint is to use GetEventProcessorIndex to determine which processor core generated each event. Because processor cores are enumerated from 0 to the number of cores in the system, this gives you nice flat array indexing scheme you can use to track which of your profile regions are actively accumulating PMCs at any given time, since there can only be as many regions active as there are cores in the machine.
That concludes today’s hint — and the entire set of hints, for that matter! Tomorrow is Halloween, which means today is your last day to complete the challenge! Good luck, and I’ll be back tomorrow to walk through my solution with you.
Thanks for the fun challenge! I knew it was going to be horrible, but it surpassed my expectations in several occasions. I won't be able to finish my API for tomorrow, but at least I helped improve the MSDN pages ever so slightly. And I did better than I expected, especially in the first half before Saint Mmozeiko's gist. I'll be finishing up the research on my own version though. I want more than just a good solution.
This challenge has been lots of fun so far, and this truly has been the most horrific API that I've ever seen, besides reg-free-com process with manifests on multiple versions of Windows for OCX files.