/* * tls.cpp */ #define WIN32_LEAN_AND_MEAN #include #include #include int __thread tls_value = 0; unsigned __stdcall thread_fn(void*) { ++tls_value; return 0; } // This is derived from the jig that I setup to explore the problems with // MT exception handling - you could probably just as easily set processors to // some value rather than tying it to the actual # of cores... int main() { // Get the number of processors available to use SYSTEM_INFO si; GetSystemInfo(&si); const unsigned processors = si.dwNumberOfProcessors; // Make a thread for every processor and assign the thread to it HANDLE threads[processors]; unsigned i; for (i=0;i