6533b872fe1ef96bd12d36ff

RESEARCH PRODUCT

Advanced C++11 Multithreading

Bertil SchmidtMoritz SchlarbJorge González-domínguezChristian Hundt

subject

Computer scienceMonitorMultithreadingThreading (manufacturing)Operating systemSemaphorecomputer.software_genreData typecomputerBottleneckSpawn (computing)Shared resource

description

Abstract The previous chapter introduced the basic concepts of multithreading using the C++11 threading API starting with basic spawn and join approaches, while finishing with non-trivial synchronization based on mutexes and condition variables. However, the major bottleneck of application performance is usually caused by contention for a shared resource. In case of mutex-based programming all participating threads usually try to acquire the same lock in parallel which effectively serializes the program for lightweight operations such as increment/decrement or updates of a single scalar value. Fortunately, modern CPUs provide dedicated commands that allow for the efficient execution of uninterruptible read-modify-write operations for scalar data types (so-called atomics). In this chapter you will learn how to improve your application's performance by enforcing race condition-free code without having to deal with the overhead of lock-based approaches.

https://doi.org/10.1016/b978-0-12-849890-3.00005-8