Avoiding race conditions among parallel processes

SharedArrays provides an easy conduit for sharing data across multiple processes. At the same time, a SharedArray is by design a global variable across all worker processes. As a general rule of thumb for every parallel program, extreme care should be given when the array is mutated. If the same memory address needs to be written by multiple processes, then these operations must be synchronized or the program could crash easily. 

The best option is to avoid mutation whenever possible.

An alternative is to assign each worker a mutually exclusive set of slots in the array so that they do not collide with each other.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset