diff options
| author | Tetralux <tetralux@teknik.io> | 2020-04-21 16:08:16 +0000 |
|---|---|---|
| committer | Tetralux <tetralux@teknik.io> | 2020-04-21 17:04:29 +0000 |
| commit | 3afa2736b7c8826527cb71ec3ca220750e0d2a9e (patch) | |
| tree | d85ede826e32aaafed2de2c7501cf399e480b3f5 /core/sync | |
| parent | 2c91c21021e1c4d1d675ee430e0d7ccf88e882be (diff) | |
Fix potential bad optimization bug in sync.Ticket_Mutex
When locking, we were not loading m.serving atomically and so the optimizer
could have hoisted the check out of the loop, thus resulting in an infinite loop.
Diffstat (limited to 'core/sync')
| -rw-r--r-- | core/sync/sync.odin | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/sync/sync.odin b/core/sync/sync.odin index 5a0512275..c6aeddd5d 100644 --- a/core/sync/sync.odin +++ b/core/sync/sync.odin @@ -17,7 +17,7 @@ ticket_mutex_init :: proc(m: ^Ticket_Mutex) { ticket_mutex_lock :: inline proc(m: ^Ticket_Mutex) { ticket := atomic_add(&m.ticket, 1, .Relaxed); - for ticket != m.serving { + for ticket != atomic_load(&m.serving, .Acquire) { yield_processor(); } } |