Wednesday, February 8, 2012

When I was writing the Multicore book, I was struck by the commonality of the Windows [1][2] and POSIX threading APIs. The concepts were common, but the names (and parameters) of the function calls were different. It looked like a relatively trivial task to write a shim to translate between the two. However, I had a book to write, so it languished until one evening last week when I actually got around to doing it.

The result is these two files
winpthread.h and
winpthread.cpp. I don't claim that these are a high fidelity port, there's plenty missing, but they should be sufficient to get a code working. In fact, there's very little complexity in the code, the only caveat is that condition variables were not introduced in Windows until Vista, and these require the use of critical sections rather than mutexes. The difference between mutexes and critical sections is that critical sections are local to a single processes whereas mutexes can be shared between processes.

Let me know if there's bugs, any improvements, or if the code is useful.

The cache parameters are output exactly as you would want to pass them into the compiler - for each cache it describes the size in KB, the line size in bytes, and the associativity.

fpversion doesn't exist on x86 systems. The next best thing is to use prtpicl to output system configuration information, and inspect that output for cache size. Here's the cache output for the same SPARC system using prtpicl.