Overview
| Artifact ID: | 4315e25c301a72fecd6f628e9a3288e9b3bf4789820f20bdf9c7cc24039feded |
|---|---|
| Ticket: | 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
Nested mutexes following TIP 509 |
| User & Date: | sebres on 2025-09-18 15:55:51 |
Changes
- icomment:
> there is no guaranteed that those memory locations are written back into main memory or synchronized with other caches. There is (as for single volatile variable).<br/> The cache of modern CPUs is always coherent (if we don't speak about GPUs or some special processors) - that is simply a basic requirement.<br/> Volatile would "guarantee" the "atomicity" and durability (of single variable) and prevents against reordering or aggressive optimization issues. One cannot use volatile to synchronize access to non-volatile data, but it doesn't happen here.<br/> So without memory barriers we can only doubt the atomicity of two variables (thread and counter) together, but because they would be changed only in the lock and because counter is interesting only if the thread owned the lock, it is OK for the second thread, because if it enters the lock, the counter must be again 0 (after unlock of other thread). I don't see the RC here right now (for the code pieces you provided before), but one have to lock closer on the whole solution (no time currently). However I am anyway for real atomic facilities, which would provide much more better variants to handle that, without to think about memory barriers and may prevent many RC scenarios.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"