[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multithreading advice on the manual
From: |
Miguel Ángel Arruga Vivas |
Subject: |
Multithreading advice on the manual |
Date: |
Fri, 09 Jun 2023 15:43:00 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi Bruno and everybody,
I've been reading the gettext manual and I've found an unfortunate
passage here[1]. The multithreaded example contains a race condition
(volatile doesn't mean atomic) and a TOCTOU error even after changing to
an atomic variable. The implementation of this pattern is what
(pthread_)call_once does, so instead of discouraging its use I propose
promoting it.
The attached patch documents the modern usage of once_flag/call_once
with a link to GNU libc manual and modifies the paragraph below the
example to suggest either pthread_once or any other equivalent primitive
provided by the system.
What do you think?
Best regards,
Miguel
[1] https://www.gnu.org/software/gettext/manual/html_node/Libraries.html
0001-Update-manual-advice-on-multiple-threads.patch
Description: Manual Update v1
- Multithreading advice on the manual,
Miguel Ángel Arruga Vivas <=