Concurrency and atomicity

Concurrent execution implies that multiple threads can run truly in parallel on multiple CPU cores. When this happens on text (code), it's good; we get higher throughput. However, the moment we run concurrently while working on shared writable data, we will have a problem with data integrity. This is because text is read-only (and executable), whereas data is read-write.

What we would really like, of course, is to be greedy and have the best of both worlds: execute code concurrently via multiple threads, but the moment we must work on shared data, stop the concurrency (parallelism), and have just one thread run through the data section sequentially until it's done, then resume parallel execution.

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

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