O'Reilly logo

Efficient C++ Performance Programming Techniques by David Mayhew, Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required