You are viewing paulmck

Previous Entry | Next Entry

TMEverywhere
The following pseudo-code fragment might be unconventional, but is meaningful, well-defined, and useful:


pthread_mutex_lock(...);
for (i = 0; i < ncpus; i++)
tid[i] = pthread_create(...);
for (i = 0; i < ncpus; i++)
pthread_join(tid[i], ...)
pthread_mutex_unlock(...);

This pseudo-code fragment uses pthread_create() to spawn one thread per CPU, then uses pthread_join() to wait for each to complete, all under the protection of pthread_mutex_lock(). The effect is to execute a lock-based critical section in parallel. Of course, the critical section would need to be quite large to justify the thread-spawning overhead, but there are many examples of large critical sections in production software. It is also legal to spawn threads within other types of critical sections, for example reader-writer locks and RCU.

What might TM do about thread spawning within a transaction?