Talk:Atomic updates

Revision as of 16:52, 18 May 2009 by rosettacode>Kevin Reid (I don't see how it is unsafe.)

Please clarify the task. Transfer of a bucket value cannot be defined atomic operation while preserving the object's invariant. The solutions presented are incorrect in this sense because they do not have transfer safe. They rather provide an unsafe transfer with locking the object externally (to the transfer). Because transfer does not keep the object's invariant it is not an operation of. So what was the purpose of the task? Just to show a use of mutex? Then the task looks superfluous, since there is already mutex task. --Dmitry-kazakov 12:44, 17 May 2009 (UTC)

I'm sorry, but I don't understand the distinctions you're making. How is the transfer operation unsafe? If you're just concerned about the nonnegative requirement, I've revised the task to include what my E implementation actually does. The difference between this task and mutex is that this task does not explicitly require the use of a mutex; my E example does not use a mutex, and it could also be implemented using, for example, wp:software transactional memory. The purpose of this task is to demonstrate a basic task in concurrency: ensuring that a data structure preserves its invariants in the presence of concurrent access. --Kevin Reid 15:17, 17 May 2009 (UTC)
Save = preserves object's integrity (invariant). E.g. sum of the bucket's values. Since a transfer of values cannot be implemented as an independent safe operation, it is unclear why it is required. My Ada solution provides atomic updates that preserve the object's invariant (sum). Can you explain why is it an incorrect solution? --Dmitry-kazakov 15:36, 18 May 2009 (UTC)
I don't understand how it is unsafe. The transfer increases one bucket by the same amount it decreases another bucket, so it preserves the invariant. The Ada solution is incorrect because the data structure does not have a general transfer operation that could be used in other ways, just two special cases. (Of course, in the end this task is arbitrary -- feel free to argue that I should change the definition.) --Kevin Reid 16:52, 18 May 2009 (UTC)
Return to "Atomic updates" page.