Skip to Content
Embedded Programming with Modern C++ Cookbook
book

Embedded Programming with Modern C++ Cookbook

by Igor Viarheichyk
April 2020
Intermediate to advanced
412 pages
9h 58m
English
Packt Publishing
Content preview from Embedded Programming with Modern C++ Cookbook

Exploring lock-free synchronization

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C++ System Programming Cookbook

C++ System Programming Cookbook

Onorato Vaticone
C++ Cookbook

C++ Cookbook

D. Ryan Stephens, Christopher Diggins, Jonathan Turkanis, Jeff Cogswell

Publisher Resources

ISBN: 9781838821043Supplemental Content