Overview
| Artifact ID: | 5d0b5632ff9505fe9cfaf577ed1c0fb35ae9da6a25a1c9ae468778935be74405 |
|---|---|
| Ticket: | 893f8cc5db3ba8bd6bed80ce89a0a75c6088a37c
Nested mutexes following TIP 509 |
| User & Date: | sebres on 2025-10-03 20:57:44 |
Changes
- closedate changed to: "2460952.37342837"
- closer changed to: "sebres"
- icomment:
<blockquote>> So now we want out of pure esoterism enter the land of undefined behavior?</blockquote> No, I didn't mean processor architecture related requirements for data alignment, that can cause UB. I meant proper alignment in sense of processor architecture, but misaligned for an operation which can require more cycles because the processor must access data from multiple, correctly aligned memory locations, effectively splitting a single logical operation into two or more distinct memory accesses that aren't performed in a single, instantaneous step. That makes the operation non atomic, but it is not an UB. There are architectures and ABIs, for instance Solaris (-m32), which require 4 bytes alignment to work properly (for most of the CPU instructions), but 8 bytes alignment to guarantee atomic read/write. <blockquote>> We want our home grown mutex struct specially crafted to have the thread id misaligned?</blockquote> It is enough to inline "home grown mutex struct" into another structure without alignment after odd count of int16/int32 members. Or use some memory allocator without necessarily aligned memory. Or something like that. <blockquote>> What about the fine __atomic_something stuff on unaligned memory then?</blockquote> I don't known such __atomic_something that can be affected by misalignment. Atomic remains atomic, no matter intrinsic (matter of compiler) or functions (the barrier is provided internally, e.g. with proper CPU instruction). In worse case you'd get a compiler error by misalignment. And last but not least, I'm basically against home made as well as reentrant mutexes - neither the former nor the latter is really needed by Tcl core.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"