Version 5: Faster Locking
What's wrong with our use of the pthreads locking calls? We suggested earlier that sometimes you don't really need the full power and flexibility of the default memory management. We are running into a similar issue with locking. Sometimes, you don't really need the full power of the pthreads library locking services. For example, pthread_mutex_lock() must check that the calling thread does not already hold the lock, otherwise we are going to deadlock. pthread_mutex_unlock() must check that the calling thread is the one that actually holds the lock. All these little checks and computations consume precious CPU cycles.
Suppose we don't really need all this locking flexibility in Version 4. Suppose that our application's ...
Get Efficient C++ Performance Programming Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.