April 2020
Intermediate to advanced
412 pages
9h 58m
English
In the preceding recipes, we learned how to synchronize access of multiple threads to shared data, using mutexes and locks. If several threads try to run critical sections of the code protected by a lock, only one thread at a time can do it. All other threads have to wait until that thread leaves the critical section.
In some cases, however, it is possible to synchronize access to shared data without mutexes and explicit locks. The idea is to use a local copy of data for modification, and then update the shared copy in a single, uninterruptible, and undividable operation.
This type of synchronization depends on the hardware. Target processors should provide some form of Compare And Swap (CAS) instruction. ...