Dirty reads

Many programmers new to these topics make a fatal assumption, and think something like this: Okay, I understand that when modifying a shared resource—like a global data structure — I will be required to treat the code as a critical section and protect it with locking, but, my code is only iterating over a global linked list; it's only reading it and never writing to it and hence, this is not a critical section and does not require protection (I'll even get brownie points for high performance).

Burst the bubble, please! It is a critical section. Why? Visualize this: while your code is iterating over the global linked list (only reading it), precisely because you have not taken a lock or synchronized in some other manner, another ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.