flâneur — a map of the web's best reading

You Don’t Know Jack about Shared Variables or Memory Models - ACM Queue

queue.acm.org · saved by 1 readers

A Google search for “Threads are evil” generates 18,000 hits, but threads—evil or not—are ubiquitous. Almost all of the processes running on a modern Windows PC use them. Software threads are typically how programmers get machines with multiple cores to work together to solve problems faster. And often they are what allow user interfaces to remain responsive while the application performs a background calculation. Threads are multiple programs running at the same time but sharing variables. Typically, every thread can access all of the application’s memory. Shared variables are either the core strength of threads or the root of their evil, depending on your perspective. They allow threads to communicate easily and quickly, but they also make it possible for threads to get in each other’s way. Although shared variables are at the core of most programs, even experts are often confused about the rules for using them. Consider the following simple example. To implement a function incr that

Explore this link on the map →

saved by