Overview
| Artifact ID: | efc906d8cfa11be1402450e1aab3533f25b19b0f26421357959eb6c24e193531 |
|---|---|
| Ticket: | 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
Nested mutexes following TIP 509 |
| User & Date: | sebres on 2025-09-18 11:51:39 |
Changes
- icomment:
<blockquote>> I am pretty sure accessing the thread and counter fields outside of any locks or memory barriers can result in stale values being read with the caller erroneously thinking it is holding the lock when it isn't and foregoing executing the `pthread_mutex_lock`.</blockquote> I don't think so, and even with aggressive optimization level the compiler wouldn't generate the code doing that. However I can imagine necessity for volatile declarations for some vars. What doesn't change my opinion about recursive mutexes. <blockquote>> Can we fix this using atomic operations? Something like [./info/10bcfc0e125e9575|this]</blockquote> Or like in [./info/a1c84c80695cce88|this] commit? It uses native atomic functions. Also it'd not need C11 or C23 (I ported that atomic facilities initially from nginx, where they appeared dozen years before C11). Anyway having that interlocked facilities in Tcl would definitely provide more benefits (I missed it often in core tcl for atomic incr/decr reference counters in structures used across threads, like in that encoding commit). Often one doesn't need mutex at all (where is no lock - there is no wait).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"