Treacherous shared counters. When several threads run concurrently… | by Alexandra (Sasha) Fedorova | Code Like A Girl
Welcome to Code Like A Girl, a space that celebrates redefining society's perceptions of women in technology. Share your story with us! Following 126 1 Listen Share More When several threads run concurrently on the cores of a multicore processor they may need to share data. In a write-sharing mode, where one thread reads and another one writes, data needs to be protected in order to avoid race conditions, which may result in lost or corrupted data. This excellent article by Hans Boehm and Sarita Adve goes in depth about all the bad things that can happen if you don’t properly synchronize your accesses to shared variables. Most programmers are aware that synchronization, typically performed with atomic instructions wrapped in locks or mutexes, is costly. Few, however, realize that even if shared variables are left unprotected, accessing them can become extremely costly on modern multicore machines. Let’s understand why. First, let’s see why anyone would ever want to use unprotected shar
Explore this link on the map →