Книга: Programming with POSIX® Threads
8.2.2.1 Too many mutexes will not help
8.2.2.1 Too many mutexes will not help
Beware, too, of exchanging a "big" mutex for lots of "tiny" mutexes. You may make matters worse. Remember, it takes time to lock a mutex, and more time to unlock that mutex. Even if you increase parallelism by designing a locking hierarchy that has very little contention, your threads may spend so much time locking and unlocking all those mutexes that they get less real work done.
Locking a mutex also affects the memory subsystem. In addition to the time you spend locking and unlocking, you may decrease the efficiency of the memory system by excessive locking. Locking a mutex, for example, might invalidate a block of cache on all processors. It might stall all bus activity within some range of physical addresses.
So find out where you really need mutexes. For example, in the previous section I suggested creating a separate mutex for each data structure. Yet, if two data structures are usually used together, or if one thread will hardly ever need to use one data structure while another thread is using the second data structure, the extra mutex may decrease your overall performance.
- Helper match
- NOTRACK target
- System tools used for debugging
- Other debugging tools
- 5.12. Обмен файлами с мобильным телефоном по Bluetooth
- CHAPTER 12 System-Monitoring Tools
- Battle for Wesnoth
- Group Management Tools
- User Management Tools
- Controlling Services at Boot with Administrative Tools
- The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake Our World
- Graphical Process and System Management Tools