Monday Dec 29, 2008
Sunday Dec 21, 2008
By yuanlin on Dec 21, 2008
A reader asked why concurrency programming is not a super-set of parallel programming since the parallel entities are also concurrent. Well, it is just like black-white vs color photography. Though black and white are two colors, the techniques in taking good black-white pictures are different from those for color pictures. One need to think and see differently in terms of contrast, texture, lighting and even composition.
Now back to our programming world. Recently while I was working on the OpenMP profiling, I fixed a concurrency bug that was related to asynchronous signals and had nothing to do with parallelism. I used a data structure to store the OpenMP context of a thread. Since an OpenMP context can be described in a tuple <current parallel region, current task region, OpenMP state, user callstack>, the data structure has several 64-bit long fields. One challenge is to update the context data structure atomically, i.e. when my program needs to report the OpenMP context, it should report a consistent context. For example, it should not report a thread is in a new parallel region but is still in an old task region. The atomicity here has nothing to do with parallelism here - the context data is thread private, so there is no sharing between different threads and there is no data race. The atomicity issue happens when a profiling signal (SIGPROF) comes while the program is in the middle of updating the fields of the context data structure. At the signal handler, the program needs to report the context and need to report them consistently. In the end, I had to crafted a way to update all the fields atomically (asynchronously safe) without masking out the SIGPROF.
- New Post @ touchdreams.net/blog: Thread Cleanup Handlers, exit(), _exit(), atexit(), and pthread_exit()
- Moving to touchdreams.net/blog
- More on Concurrency vs Parallelism
- Extending the OpenMP profiling API for OpenMP 3.0
- Sun Studio Express 11/08
- New LEGO in Store: Sun Studio Express 07/08 with OpenMP 3.0 Support
- Gulf of Execution
- Think in Parallel or Not
- Non-concurrency Analysis Used in PTP
- Maximum Automation for Mundane Tasks