Posted Dec 27, 2007 18:57 UTC (Thu) by PaulMcKenney (subscriber, #9624)
[Link]
Indeed! As with the preceding example, there must be some sort of mutual exclusion in play,
and as in the preceding example, this mutual exclusion is not shown explicitly.
One approach, as you say, would be to add locking, perhaps similar to that described in the
answer to Quick Quiz 4 (but for the deletion example). Another approach would be to hold a
mutex (in the old style, "semaphore") across the entire code segment. Yet a third approach
would be to permit only a single designated task to do updates (in which case the code would
remain as is). There are other approaches as well.
In any case, I am glad to see that people are sensitized to the need for mutual exclusion in
parallel code!