| 1 |
# SOME DESCRIPTIVE TITLE |
| 2 |
# Copyright (C) YEAR Free Software Foundation, Inc. |
| 3 |
# This file is distributed under the same license as the PACKAGE package. |
| 4 |
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 |
# |
| 6 |
#, fuzzy |
| 7 |
msgid "" |
| 8 |
msgstr "" |
| 9 |
"Project-Id-Version: PACKAGE VERSION\n" |
| 10 |
"POT-Creation-Date: 2026-06-05 06:25+0200\n" |
| 11 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 12 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 13 |
"Language-Team: LANGUAGE <[email protected]>\n" |
| 14 |
"Language: \n" |
| 15 |
"MIME-Version: 1.0\n" |
| 16 |
"Content-Type: text/plain; charset=UTF-8\n" |
| 17 |
"Content-Transfer-Encoding: 8bit\n" |
| 18 |
|
| 19 |
#. type: TH |
| 20 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 21 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 22 |
#, no-wrap |
| 23 |
msgid "futex" |
| 24 |
msgstr "" |
| 25 |
|
| 26 |
#. type: TH |
| 27 |
#: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed |
| 28 |
#, no-wrap |
| 29 |
msgid "2026-02-14" |
| 30 |
msgstr "" |
| 31 |
|
| 32 |
#. type: TH |
| 33 |
#: archlinux debian-unstable |
| 34 |
#, no-wrap |
| 35 |
msgid "Linux man-pages 6.18" |
| 36 |
msgstr "" |
| 37 |
|
| 38 |
#. type: SH |
| 39 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 40 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 41 |
#, no-wrap |
| 42 |
msgid "NAME" |
| 43 |
msgstr "" |
| 44 |
|
| 45 |
#. type: Plain text |
| 46 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 47 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 48 |
msgid "futex - fast user-space locking" |
| 49 |
msgstr "" |
| 50 |
|
| 51 |
#. type: SH |
| 52 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 53 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 54 |
#, no-wrap |
| 55 |
msgid "LIBRARY" |
| 56 |
msgstr "" |
| 57 |
|
| 58 |
#. type: Plain text |
| 59 |
#: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron |
| 60 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 61 |
msgid "Standard C library (I<libc>,\\ I<-lc>)" |
| 62 |
msgstr "" |
| 63 |
|
| 64 |
#. type: SH |
| 65 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 66 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 67 |
#, no-wrap |
| 68 |
msgid "SYNOPSIS" |
| 69 |
msgstr "" |
| 70 |
|
| 71 |
#. type: Plain text |
| 72 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 73 |
#: opensuse-tumbleweed |
| 74 |
#, no-wrap |
| 75 |
msgid "" |
| 76 |
"B<#include E<lt>linux/futex.hE<gt>> /* Definition of B<FUTEX_*> constants */\n" |
| 77 |
"B<#include E<lt>sys/syscall.hE<gt>> /* Definition of B<SYS_*> constants */\n" |
| 78 |
"B<#include E<lt>unistd.hE<gt>>\n" |
| 79 |
msgstr "" |
| 80 |
|
| 81 |
#. type: Plain text |
| 82 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 83 |
#: opensuse-tumbleweed |
| 84 |
#, no-wrap |
| 85 |
msgid "B<long syscall(SYS_futex, uint32_t *>I<uaddr>B<, int >I<op>B<, ...);>\n" |
| 86 |
msgstr "" |
| 87 |
|
| 88 |
#. type: SH |
| 89 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 90 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 91 |
#, no-wrap |
| 92 |
msgid "DESCRIPTION" |
| 93 |
msgstr "" |
| 94 |
|
| 95 |
#. type: Plain text |
| 96 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 97 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 98 |
msgid "" |
| 99 |
"The B<futex>() system call provides a method for waiting until a certain " |
| 100 |
"condition becomes true. It is typically used as a blocking construct in the " |
| 101 |
"context of shared-memory synchronization. When using futexes, the majority " |
| 102 |
"of the synchronization operations are performed in user space. A user-space " |
| 103 |
"program employs the B<futex>() system call only when it is likely that the " |
| 104 |
"program has to block for a longer time until the condition becomes true. " |
| 105 |
"Other B<futex>() operations can be used to wake any processes or threads " |
| 106 |
"waiting for a particular condition." |
| 107 |
msgstr "" |
| 108 |
|
| 109 |
#. type: Plain text |
| 110 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 111 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 112 |
msgid "" |
| 113 |
"A futex is a 32-bit value\\[em]referred to below as a I<futex word>\\" |
| 114 |
"[em]whose address is supplied to the B<futex>() system call. (Futexes are " |
| 115 |
"32 bits in size on all platforms, including 64-bit systems.) All futex " |
| 116 |
"operations are governed by this value. In order to share a futex between " |
| 117 |
"processes, the futex is placed in a region of shared memory, created using " |
| 118 |
"(for example) B<mmap>(2) or B<shmat>(2). (Thus, the futex word may have " |
| 119 |
"different virtual addresses in different processes, but these addresses all " |
| 120 |
"refer to the same location in physical memory.) In a multithreaded program, " |
| 121 |
"it is sufficient to place the futex word in a global variable shared by all " |
| 122 |
"threads." |
| 123 |
msgstr "" |
| 124 |
|
| 125 |
# |
| 126 |
#. #-#-#-#-# archlinux: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 127 |
#. Notes from Darren Hart (Dec 2015): |
| 128 |
#. Totally ordered with respect futex operations refers to semantics |
| 129 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 130 |
#. memory reads and writes. The kernel futex operations are protected |
| 131 |
#. by spinlocks, which ensure that all operations are serialized |
| 132 |
#. with respect to one another. |
| 133 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 134 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 135 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 136 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 137 |
#. pointer to the memory-barrier documentation? |
| 138 |
#. FIXME(Torvald Riegel): |
| 139 |
#. Eventually we want to have some text in NOTES to satisfy |
| 140 |
#. the reference in the following sentence |
| 141 |
#. See NOTES for a detailed specification of |
| 142 |
#. the synchronization semantics. |
| 143 |
#. type: Plain text |
| 144 |
#. #-#-#-#-# debian-trixie: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 145 |
#. Notes from Darren Hart (Dec 2015): |
| 146 |
#. Totally ordered with respect futex operations refers to semantics |
| 147 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 148 |
#. memory reads and writes. The kernel futex operations are protected |
| 149 |
#. by spinlocks, which ensure that all operations are serialized |
| 150 |
#. with respect to one another. |
| 151 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 152 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 153 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 154 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 155 |
#. pointer to the memory-barrier documentation? |
| 156 |
#. FIXME(Torvald Riegel): |
| 157 |
#. Eventually we want to have some text in NOTES to satisfy |
| 158 |
#. the reference in the following sentence |
| 159 |
#. See NOTES for a detailed specification of |
| 160 |
#. the synchronization semantics. |
| 161 |
#. type: Plain text |
| 162 |
#. #-#-#-#-# debian-unstable: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 163 |
#. Notes from Darren Hart (Dec 2015): |
| 164 |
#. Totally ordered with respect futex operations refers to semantics |
| 165 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 166 |
#. memory reads and writes. The kernel futex operations are protected |
| 167 |
#. by spinlocks, which ensure that all operations are serialized |
| 168 |
#. with respect to one another. |
| 169 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 170 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 171 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 172 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 173 |
#. pointer to the memory-barrier documentation? |
| 174 |
#. FIXME(Torvald Riegel): |
| 175 |
#. Eventually we want to have some text in NOTES to satisfy |
| 176 |
#. the reference in the following sentence |
| 177 |
#. See NOTES for a detailed specification of |
| 178 |
#. the synchronization semantics. |
| 179 |
#. type: Plain text |
| 180 |
#. #-#-#-#-# fedora-44: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 181 |
#. Notes from Darren Hart (Dec 2015): |
| 182 |
#. Totally ordered with respect futex operations refers to semantics |
| 183 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 184 |
#. memory reads and writes. The kernel futex operations are protected |
| 185 |
#. by spinlocks, which ensure that all operations are serialized |
| 186 |
#. with respect to one another. |
| 187 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 188 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 189 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 190 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 191 |
#. pointer to the memory-barrier documentation? |
| 192 |
#. FIXME(Torvald Riegel): |
| 193 |
#. Eventually we want to have some text in NOTES to satisfy |
| 194 |
#. the reference in the following sentence |
| 195 |
#. See NOTES for a detailed specification of |
| 196 |
#. the synchronization semantics. |
| 197 |
#. type: Plain text |
| 198 |
#. #-#-#-#-# fedora-rawhide: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 199 |
#. Notes from Darren Hart (Dec 2015): |
| 200 |
#. Totally ordered with respect futex operations refers to semantics |
| 201 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 202 |
#. memory reads and writes. The kernel futex operations are protected |
| 203 |
#. by spinlocks, which ensure that all operations are serialized |
| 204 |
#. with respect to one another. |
| 205 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 206 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 207 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 208 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 209 |
#. pointer to the memory-barrier documentation? |
| 210 |
#. FIXME(Torvald Riegel): |
| 211 |
#. Eventually we want to have some text in NOTES to satisfy |
| 212 |
#. the reference in the following sentence |
| 213 |
#. See NOTES for a detailed specification of |
| 214 |
#. the synchronization semantics. |
| 215 |
#. type: Plain text |
| 216 |
#. #-#-#-#-# mageia-cauldron: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 217 |
#. Notes from Darren Hart (Dec 2015): |
| 218 |
#. Totally ordered with respect futex operations refers to semantics |
| 219 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 220 |
#. memory reads and writes. The kernel futex operations are protected |
| 221 |
#. by spinlocks, which ensure that all operations are serialized |
| 222 |
#. with respect to one another. |
| 223 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 224 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 225 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 226 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 227 |
#. pointer to the memory-barrier documentation? |
| 228 |
#. FIXME(Torvald Riegel): |
| 229 |
#. Eventually we want to have some text in NOTES to satisfy |
| 230 |
#. the reference in the following sentence |
| 231 |
#. See NOTES for a detailed specification of |
| 232 |
#. the synchronization semantics. |
| 233 |
#. type: Plain text |
| 234 |
#. #-#-#-#-# opensuse-leap-16-1: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 235 |
#. Notes from Darren Hart (Dec 2015): |
| 236 |
#. Totally ordered with respect futex operations refers to semantics |
| 237 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 238 |
#. memory reads and writes. The kernel futex operations are protected |
| 239 |
#. by spinlocks, which ensure that all operations are serialized |
| 240 |
#. with respect to one another. |
| 241 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 242 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 243 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 244 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 245 |
#. pointer to the memory-barrier documentation? |
| 246 |
#. FIXME(Torvald Riegel): |
| 247 |
#. Eventually we want to have some text in NOTES to satisfy |
| 248 |
#. the reference in the following sentence |
| 249 |
#. See NOTES for a detailed specification of |
| 250 |
#. the synchronization semantics. |
| 251 |
#. type: Plain text |
| 252 |
#. #-#-#-#-# opensuse-tumbleweed: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 253 |
#. Notes from Darren Hart (Dec 2015): |
| 254 |
#. Totally ordered with respect futex operations refers to semantics |
| 255 |
#. of the ACQUIRE/RELEASE operations and how they impact ordering of |
| 256 |
#. memory reads and writes. The kernel futex operations are protected |
| 257 |
#. by spinlocks, which ensure that all operations are serialized |
| 258 |
#. with respect to one another. |
| 259 |
#. This is a lot to attempt to define in this document. Perhaps a |
| 260 |
#. reference to linux/Documentation/memory-barriers.txt as a footnote |
| 261 |
#. would be sufficient? Or perhaps for this manual, "serialized" would |
| 262 |
#. be sufficient, with a footnote regarding "totally ordered" and a |
| 263 |
#. pointer to the memory-barrier documentation? |
| 264 |
#. FIXME(Torvald Riegel): |
| 265 |
#. Eventually we want to have some text in NOTES to satisfy |
| 266 |
#. the reference in the following sentence |
| 267 |
#. See NOTES for a detailed specification of |
| 268 |
#. the synchronization semantics. |
| 269 |
#. type: Plain text |
| 270 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 271 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 272 |
msgid "" |
| 273 |
"When executing a futex operation that requests to block a thread, the kernel " |
| 274 |
"will block only if the futex word has the value that the calling thread " |
| 275 |
"supplied (as one of the arguments of the B<futex>() call) as the expected " |
| 276 |
"value of the futex word. The loading of the futex word's value, the " |
| 277 |
"comparison of that value with the expected value, and the actual blocking " |
| 278 |
"will happen atomically and will be totally ordered with respect to " |
| 279 |
"concurrent operations performed by other threads on the same futex word. " |
| 280 |
"Thus, the futex word is used to connect the synchronization in user space " |
| 281 |
"with the implementation of blocking by the kernel. Analogously to an atomic " |
| 282 |
"compare-and-exchange operation that potentially changes shared memory, " |
| 283 |
"blocking via a futex is an atomic compare-and-block operation." |
| 284 |
msgstr "" |
| 285 |
|
| 286 |
#. type: Plain text |
| 287 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 288 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 289 |
msgid "" |
| 290 |
"One use of futexes is for implementing locks. The state of the lock (i.e., " |
| 291 |
"acquired or not acquired) can be represented as an atomically accessed flag " |
| 292 |
"in shared memory. In the uncontended case, a thread can access or modify " |
| 293 |
"the lock state with atomic instructions, for example atomically changing it " |
| 294 |
"from not acquired to acquired using an atomic compare-and-exchange " |
| 295 |
"instruction. (Such instructions are performed entirely in user mode, and " |
| 296 |
"the kernel maintains no information about the lock state.) On the other " |
| 297 |
"hand, a thread may be unable to acquire a lock because it is already " |
| 298 |
"acquired by another thread. It then may pass the lock's flag as a futex " |
| 299 |
"word and the value representing the acquired state as the expected value to " |
| 300 |
"a B<futex>() wait operation. This B<futex>() operation will block if and " |
| 301 |
"only if the lock is still acquired (i.e., the value in the futex word still " |
| 302 |
"matches the \"acquired state\"). When releasing the lock, a thread has to " |
| 303 |
"first reset the lock state to not acquired and then execute a futex " |
| 304 |
"operation that wakes threads blocked on the lock flag used as a futex word " |
| 305 |
"(this can be further optimized to avoid unnecessary wake-ups). See " |
| 306 |
"B<futex>(7) for more detail on how to use futexes." |
| 307 |
msgstr "" |
| 308 |
|
| 309 |
#. type: Plain text |
| 310 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 311 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 312 |
msgid "" |
| 313 |
"Besides the basic wait and wake-up futex functionality, there are further " |
| 314 |
"futex operations aimed at supporting more complex use cases." |
| 315 |
msgstr "" |
| 316 |
|
| 317 |
#. type: Plain text |
| 318 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 319 |
#: opensuse-tumbleweed |
| 320 |
msgid "" |
| 321 |
"Note that no explicit initialization or destruction is necessary to use " |
| 322 |
"futexes; the kernel maintains a futex (i.e., the kernel-internal " |
| 323 |
"implementation artifact) only while operations such as " |
| 324 |
"B<FUTEX_WAIT>(2const) are being performed on a particular futex word." |
| 325 |
msgstr "" |
| 326 |
|
| 327 |
#. type: SS |
| 328 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 329 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 330 |
#, no-wrap |
| 331 |
msgid "Arguments" |
| 332 |
msgstr "" |
| 333 |
|
| 334 |
# |
| 335 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 336 |
#. type: Plain text |
| 337 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 338 |
#: opensuse-tumbleweed |
| 339 |
msgid "" |
| 340 |
"The I<uaddr> argument points to the futex word. On all platforms, futexes " |
| 341 |
"are four-byte integers that must be aligned on a four-byte boundary. The " |
| 342 |
"operation to perform on the futex is specified in the I<op> argument." |
| 343 |
msgstr "" |
| 344 |
|
| 345 |
#. type: SS |
| 346 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 347 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 348 |
#, no-wrap |
| 349 |
msgid "Futex operations" |
| 350 |
msgstr "" |
| 351 |
|
| 352 |
#. type: Plain text |
| 353 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 354 |
#: opensuse-tumbleweed |
| 355 |
msgid "" |
| 356 |
"The I<op> argument consists of two parts: a command that specifies the " |
| 357 |
"operation to be performed, bitwise ORed with zero or more options that " |
| 358 |
"modify the behavior of the operation. The options that may be included in " |
| 359 |
"I<op> are as follows:" |
| 360 |
msgstr "" |
| 361 |
|
| 362 |
#. type: TP |
| 363 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 364 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 365 |
#, no-wrap |
| 366 |
msgid "B<FUTEX_PRIVATE_FLAG> (since Linux 2.6.22)" |
| 367 |
msgstr "" |
| 368 |
|
| 369 |
#. commit 34f01cc1f512fa783302982776895c73714ebbc2 |
| 370 |
#. I.e., It allows the kernel choose the fast path for validating |
| 371 |
#. the user-space address and avoids expensive VMA lookups, |
| 372 |
#. taking reference counts on file backing store, and so on. |
| 373 |
#. type: Plain text |
| 374 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 375 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 376 |
msgid "" |
| 377 |
"This option bit can be employed with all futex operations. It tells the " |
| 378 |
"kernel that the futex is process-private and not shared with another process " |
| 379 |
"(i.e., it is being used for synchronization only between threads of the same " |
| 380 |
"process). This allows the kernel to make some additional performance " |
| 381 |
"optimizations." |
| 382 |
msgstr "" |
| 383 |
|
| 384 |
#. #-#-#-#-# archlinux: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 385 |
#. except the obsolete FUTEX_FD(2const), for which the "private" flag was |
| 386 |
#. meaningless |
| 387 |
#. type: Plain text |
| 388 |
#. #-#-#-#-# debian-trixie: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 389 |
#. except the obsolete FUTEX_FD, for which the "private" flag was |
| 390 |
#. meaningless |
| 391 |
#. type: Plain text |
| 392 |
#. #-#-#-#-# debian-unstable: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 393 |
#. except the obsolete FUTEX_FD(2const), for which the "private" flag was |
| 394 |
#. meaningless |
| 395 |
#. type: Plain text |
| 396 |
#. #-#-#-#-# fedora-44: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 397 |
#. except the obsolete FUTEX_FD, for which the "private" flag was |
| 398 |
#. meaningless |
| 399 |
#. type: Plain text |
| 400 |
#. #-#-#-#-# fedora-rawhide: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 401 |
#. except the obsolete FUTEX_FD, for which the "private" flag was |
| 402 |
#. meaningless |
| 403 |
#. type: Plain text |
| 404 |
#. #-#-#-#-# mageia-cauldron: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 405 |
#. except the obsolete FUTEX_FD(2const), for which the "private" flag was |
| 406 |
#. meaningless |
| 407 |
#. type: Plain text |
| 408 |
#. #-#-#-#-# opensuse-leap-16-1: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 409 |
#. except the obsolete FUTEX_FD(2const), for which the "private" flag was |
| 410 |
#. meaningless |
| 411 |
#. type: Plain text |
| 412 |
#. #-#-#-#-# opensuse-tumbleweed: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 413 |
#. except the obsolete FUTEX_FD(2const), for which the "private" flag was |
| 414 |
#. meaningless |
| 415 |
#. type: Plain text |
| 416 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 417 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 418 |
msgid "" |
| 419 |
"As a convenience, I<E<lt>linux/futex.hE<gt>> defines a set of constants with " |
| 420 |
"the suffix B<_PRIVATE> that are equivalents of all of the operations listed " |
| 421 |
"below, but with the B<FUTEX_PRIVATE_FLAG> ORed into the constant value. " |
| 422 |
"Thus, there are B<FUTEX_WAIT_PRIVATE>, B<FUTEX_WAKE_PRIVATE>, and so on." |
| 423 |
msgstr "" |
| 424 |
|
| 425 |
#. type: TP |
| 426 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 427 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 428 |
#, no-wrap |
| 429 |
msgid "B<FUTEX_CLOCK_REALTIME> (since Linux 2.6.28)" |
| 430 |
msgstr "" |
| 431 |
|
| 432 |
#. commit 1acdac104668a0834cfa267de9946fac7764d486 |
| 433 |
#. commit 337f13046ff03717a9e99675284a817527440a49 |
| 434 |
#. commit bf22a6976897977b0a3f1aeba6823c959fc4fdae |
| 435 |
#. type: Plain text |
| 436 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 437 |
#: opensuse-tumbleweed |
| 438 |
msgid "" |
| 439 |
"This option bit can be employed only with the B<FUTEX_WAIT_BITSET>(2const), " |
| 440 |
"B<FUTEX_WAIT_REQUEUE_PI>(2const), (since Linux 4.5) B<FUTEX_WAIT>(2const), " |
| 441 |
"and (since Linux 5.14) B<FUTEX_LOCK_PI2>(2const) operations." |
| 442 |
msgstr "" |
| 443 |
|
| 444 |
#. type: Plain text |
| 445 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 446 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 447 |
msgid "" |
| 448 |
"If this option is set, the kernel measures the I<timeout> against the " |
| 449 |
"B<CLOCK_REALTIME> clock." |
| 450 |
msgstr "" |
| 451 |
|
| 452 |
#. type: Plain text |
| 453 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 454 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 455 |
msgid "" |
| 456 |
"If this option is not set, the kernel measures the I<timeout> against the " |
| 457 |
"B<CLOCK_MONOTONIC> clock." |
| 458 |
msgstr "" |
| 459 |
|
| 460 |
# |
| 461 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 462 |
#. type: Plain text |
| 463 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 464 |
#: opensuse-tumbleweed |
| 465 |
msgid "The operation specified in I<op> is one of the following:" |
| 466 |
msgstr "" |
| 467 |
|
| 468 |
#. type: TP |
| 469 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 470 |
#: opensuse-tumbleweed |
| 471 |
#, no-wrap |
| 472 |
msgid "B<FUTEX_WAIT>(2const)" |
| 473 |
msgstr "" |
| 474 |
|
| 475 |
#. type: TQ |
| 476 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 477 |
#: opensuse-tumbleweed |
| 478 |
#, no-wrap |
| 479 |
msgid "B<FUTEX_WAKE>(2const)" |
| 480 |
msgstr "" |
| 481 |
|
| 482 |
#. type: TQ |
| 483 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 484 |
#: opensuse-tumbleweed |
| 485 |
#, no-wrap |
| 486 |
msgid "B<FUTEX_FD>(2const)" |
| 487 |
msgstr "" |
| 488 |
|
| 489 |
#. type: TQ |
| 490 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 491 |
#: opensuse-tumbleweed |
| 492 |
#, no-wrap |
| 493 |
msgid "B<FUTEX_REQUEUE>(2const)" |
| 494 |
msgstr "" |
| 495 |
|
| 496 |
#. type: TQ |
| 497 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 498 |
#: opensuse-tumbleweed |
| 499 |
#, no-wrap |
| 500 |
msgid "B<FUTEX_CMP_REQUEUE>(2const)" |
| 501 |
msgstr "" |
| 502 |
|
| 503 |
#. type: TQ |
| 504 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 505 |
#: opensuse-tumbleweed |
| 506 |
#, no-wrap |
| 507 |
msgid "B<FUTEX_WAKE_OP>(2const)" |
| 508 |
msgstr "" |
| 509 |
|
| 510 |
#. type: TQ |
| 511 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 512 |
#: opensuse-tumbleweed |
| 513 |
#, no-wrap |
| 514 |
msgid "B<FUTEX_WAIT_BITSET>(2const)" |
| 515 |
msgstr "" |
| 516 |
|
| 517 |
#. type: TQ |
| 518 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 519 |
#: opensuse-tumbleweed |
| 520 |
#, no-wrap |
| 521 |
msgid "B<FUTEX_WAKE_BITSET>(2const)" |
| 522 |
msgstr "" |
| 523 |
|
| 524 |
#. type: SS |
| 525 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 526 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 527 |
#, no-wrap |
| 528 |
msgid "Priority-inheritance futexes" |
| 529 |
msgstr "" |
| 530 |
|
| 531 |
#. type: Plain text |
| 532 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 533 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 534 |
msgid "" |
| 535 |
"Linux supports priority-inheritance (PI) futexes in order to handle priority-" |
| 536 |
"inversion problems that can be encountered with normal futex locks. " |
| 537 |
"Priority inversion is the problem that occurs when a high-priority task is " |
| 538 |
"blocked waiting to acquire a lock held by a low-priority task, while tasks " |
| 539 |
"at an intermediate priority continuously preempt the low-priority task from " |
| 540 |
"the CPU. Consequently, the low-priority task makes no progress toward " |
| 541 |
"releasing the lock, and the high-priority task remains blocked." |
| 542 |
msgstr "" |
| 543 |
|
| 544 |
#. type: Plain text |
| 545 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 546 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 547 |
msgid "" |
| 548 |
"Priority inheritance is a mechanism for dealing with the priority-inversion " |
| 549 |
"problem. With this mechanism, when a high-priority task becomes blocked by " |
| 550 |
"a lock held by a low-priority task, the priority of the low-priority task is " |
| 551 |
"temporarily raised to that of the high-priority task, so that it is not " |
| 552 |
"preempted by any intermediate level tasks, and can thus make progress toward " |
| 553 |
"releasing the lock. To be effective, priority inheritance must be " |
| 554 |
"transitive, meaning that if a high-priority task blocks on a lock held by a " |
| 555 |
"lower-priority task that is itself blocked by a lock held by another " |
| 556 |
"intermediate-priority task (and so on, for chains of arbitrary length), then " |
| 557 |
"both of those tasks (or more generally, all of the tasks in a lock chain) " |
| 558 |
"have their priorities raised to be the same as the high-priority task." |
| 559 |
msgstr "" |
| 560 |
|
| 561 |
# |
| 562 |
#. #-#-#-#-# archlinux: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 563 |
#. Quoting Darren Hart: |
| 564 |
#. These opcodes paired with the PI futex value policy (described below) |
| 565 |
#. defines a "futex" as PI aware. These were created very specifically |
| 566 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 567 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 568 |
#. there is a lot of policy and scaffolding that has to be built up |
| 569 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 570 |
#. type: Plain text |
| 571 |
#. #-#-#-#-# debian-trixie: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 572 |
#. Quoting Darren Hart: |
| 573 |
#. These opcodes paired with the PI futex value policy (described below) |
| 574 |
#. defines a "futex" as PI aware. These were created very specifically |
| 575 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 576 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 577 |
#. there is a lot of policy and scaffolding that has to be built up |
| 578 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 579 |
#. type: Plain text |
| 580 |
#. #-#-#-#-# debian-unstable: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 581 |
#. Quoting Darren Hart: |
| 582 |
#. These opcodes paired with the PI futex value policy (described below) |
| 583 |
#. defines a "futex" as PI aware. These were created very specifically |
| 584 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 585 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 586 |
#. there is a lot of policy and scaffolding that has to be built up |
| 587 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 588 |
#. type: Plain text |
| 589 |
#. #-#-#-#-# fedora-44: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 590 |
#. Quoting Darren Hart: |
| 591 |
#. These opcodes paired with the PI futex value policy (described below) |
| 592 |
#. defines a "futex" as PI aware. These were created very specifically |
| 593 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 594 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 595 |
#. there is a lot of policy and scaffolding that has to be built up |
| 596 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 597 |
#. type: Plain text |
| 598 |
#. #-#-#-#-# fedora-rawhide: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 599 |
#. Quoting Darren Hart: |
| 600 |
#. These opcodes paired with the PI futex value policy (described below) |
| 601 |
#. defines a "futex" as PI aware. These were created very specifically |
| 602 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 603 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 604 |
#. there is a lot of policy and scaffolding that has to be built up |
| 605 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 606 |
#. type: Plain text |
| 607 |
#. #-#-#-#-# mageia-cauldron: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 608 |
#. Quoting Darren Hart: |
| 609 |
#. These opcodes paired with the PI futex value policy (described below) |
| 610 |
#. defines a "futex" as PI aware. These were created very specifically |
| 611 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 612 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 613 |
#. there is a lot of policy and scaffolding that has to be built up |
| 614 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 615 |
#. type: Plain text |
| 616 |
#. #-#-#-#-# opensuse-leap-16-1: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 617 |
#. Quoting Darren Hart: |
| 618 |
#. These opcodes paired with the PI futex value policy (described below) |
| 619 |
#. defines a "futex" as PI aware. These were created very specifically |
| 620 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 621 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 622 |
#. there is a lot of policy and scaffolding that has to be built up |
| 623 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 624 |
#. type: Plain text |
| 625 |
#. #-#-#-#-# opensuse-tumbleweed: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 626 |
#. Quoting Darren Hart: |
| 627 |
#. These opcodes paired with the PI futex value policy (described below) |
| 628 |
#. defines a "futex" as PI aware. These were created very specifically |
| 629 |
#. in support of PI pthread_mutexes, so it makes a lot more sense to |
| 630 |
#. talk about a PI aware pthread_mutex, than a PI aware futex, since |
| 631 |
#. there is a lot of policy and scaffolding that has to be built up |
| 632 |
#. around it to use it properly (this is what a PI pthread_mutex is). |
| 633 |
#. type: Plain text |
| 634 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 635 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 636 |
msgid "" |
| 637 |
"From a user-space perspective, what makes a futex PI-aware is a policy " |
| 638 |
"agreement (described below) between user space and the kernel about the " |
| 639 |
"value of the futex word, coupled with the use of the PI-futex operations " |
| 640 |
"described below. (Unlike the other futex operations described above, the PI-" |
| 641 |
"futex operations are designed for the implementation of very specific IPC " |
| 642 |
"mechanisms.)" |
| 643 |
msgstr "" |
| 644 |
|
| 645 |
#. mtk: The following text is drawn from the Hart/Guniguntala paper |
| 646 |
#. (listed in SEE ALSO), but I have reworded some pieces |
| 647 |
#. significantly. |
| 648 |
#. type: Plain text |
| 649 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 650 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 651 |
msgid "" |
| 652 |
"The PI-futex operations described below differ from the other futex " |
| 653 |
"operations in that they impose policy on the use of the value of the futex " |
| 654 |
"word:" |
| 655 |
msgstr "" |
| 656 |
|
| 657 |
#. type: IP |
| 658 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 659 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 660 |
#, no-wrap |
| 661 |
msgid "\\[bu]" |
| 662 |
msgstr "" |
| 663 |
|
| 664 |
#. type: Plain text |
| 665 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 666 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 667 |
msgid "If the lock is not acquired, the futex word's value shall be 0." |
| 668 |
msgstr "" |
| 669 |
|
| 670 |
#. type: Plain text |
| 671 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 672 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 673 |
msgid "" |
| 674 |
"If the lock is acquired, the futex word's value shall be the thread ID (TID; " |
| 675 |
"see B<gettid>(2)) of the owning thread." |
| 676 |
msgstr "" |
| 677 |
|
| 678 |
#. type: Plain text |
| 679 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 680 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 681 |
msgid "" |
| 682 |
"If the lock is owned and there are threads contending for the lock, then the " |
| 683 |
"B<FUTEX_WAITERS> bit shall be set in the futex word's value; in other words, " |
| 684 |
"this value is:" |
| 685 |
msgstr "" |
| 686 |
|
| 687 |
#. type: Plain text |
| 688 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 689 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 690 |
#, no-wrap |
| 691 |
msgid "FUTEX_WAITERS | TID\n" |
| 692 |
msgstr "" |
| 693 |
|
| 694 |
#. type: Plain text |
| 695 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 696 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 697 |
msgid "" |
| 698 |
"(Note that is invalid for a PI futex word to have no owner and " |
| 699 |
"B<FUTEX_WAITERS> set.)" |
| 700 |
msgstr "" |
| 701 |
|
| 702 |
#. type: Plain text |
| 703 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 704 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 705 |
msgid "" |
| 706 |
"With this policy in place, a user-space application can acquire an " |
| 707 |
"unacquired lock or release a lock using atomic instructions executed in user " |
| 708 |
"mode (e.g., a compare-and-swap operation such as I<cmpxchg> on the x86 " |
| 709 |
"architecture). Acquiring a lock simply consists of using compare-and-swap " |
| 710 |
"to atomically set the futex word's value to the caller's TID if its previous " |
| 711 |
"value was 0. Releasing a lock requires using compare-and-swap to set the " |
| 712 |
"futex word's value to 0 if the previous value was the expected TID." |
| 713 |
msgstr "" |
| 714 |
|
| 715 |
#. type: Plain text |
| 716 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 717 |
#: opensuse-tumbleweed |
| 718 |
msgid "" |
| 719 |
"If a futex is already acquired (i.e., has a nonzero value), waiters must " |
| 720 |
"employ the B<FUTEX_LOCK_PI>(2const) or B<FUTEX_LOCK_PI2>(2const) " |
| 721 |
"operations to acquire the lock. If other threads are waiting for the lock, " |
| 722 |
"then the B<FUTEX_WAITERS> bit is set in the futex value; in this case, the " |
| 723 |
"lock owner must employ the B<FUTEX_UNLOCK_PI>(2const) operation to release " |
| 724 |
"the lock." |
| 725 |
msgstr "" |
| 726 |
|
| 727 |
#. type: Plain text |
| 728 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 729 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 730 |
msgid "" |
| 731 |
"In the cases where callers are forced into the kernel (i.e., required to " |
| 732 |
"perform a B<futex>() call), they then deal directly with a so-called RT-" |
| 733 |
"mutex, a kernel locking mechanism which implements the required priority-" |
| 734 |
"inheritance semantics. After the RT-mutex is acquired, the futex value is " |
| 735 |
"updated accordingly, before the calling thread returns to user space." |
| 736 |
msgstr "" |
| 737 |
|
| 738 |
#. #-#-#-#-# archlinux: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 739 |
#. tglx (July 2015): |
| 740 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 741 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 742 |
#. includes handing over the rtmutex which represents the futex in the |
| 743 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 744 |
#. owner must be the same, except for the update period which is |
| 745 |
#. serialized by the futex internal locking. That means the kernel must |
| 746 |
#. update the user-space value prior to returning to user space |
| 747 |
#. type: Plain text |
| 748 |
#. #-#-#-#-# debian-trixie: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 749 |
#. tglx (July 2015): |
| 750 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 751 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 752 |
#. includes handing over the rtmutex which represents the futex in the |
| 753 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 754 |
#. owner must be the same, except for the update period which is |
| 755 |
#. serialized by the futex internal locking. That means the kernel must |
| 756 |
#. update the user-space value prior to returning to user space |
| 757 |
#. type: Plain text |
| 758 |
#. #-#-#-#-# debian-unstable: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 759 |
#. tglx (July 2015): |
| 760 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 761 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 762 |
#. includes handing over the rtmutex which represents the futex in the |
| 763 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 764 |
#. owner must be the same, except for the update period which is |
| 765 |
#. serialized by the futex internal locking. That means the kernel must |
| 766 |
#. update the user-space value prior to returning to user space |
| 767 |
#. type: Plain text |
| 768 |
#. #-#-#-#-# fedora-44: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 769 |
#. tglx (July 2015): |
| 770 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 771 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 772 |
#. includes handing over the rtmutex which represents the futex in the |
| 773 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 774 |
#. owner must be the same, except for the update period which is |
| 775 |
#. serialized by the futex internal locking. That means the kernel must |
| 776 |
#. update the user-space value prior to returning to user space |
| 777 |
#. type: Plain text |
| 778 |
#. #-#-#-#-# fedora-rawhide: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 779 |
#. tglx (July 2015): |
| 780 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 781 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 782 |
#. includes handing over the rtmutex which represents the futex in the |
| 783 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 784 |
#. owner must be the same, except for the update period which is |
| 785 |
#. serialized by the futex internal locking. That means the kernel must |
| 786 |
#. update the user-space value prior to returning to user space |
| 787 |
#. type: Plain text |
| 788 |
#. #-#-#-#-# mageia-cauldron: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 789 |
#. tglx (July 2015): |
| 790 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 791 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 792 |
#. includes handing over the rtmutex which represents the futex in the |
| 793 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 794 |
#. owner must be the same, except for the update period which is |
| 795 |
#. serialized by the futex internal locking. That means the kernel must |
| 796 |
#. update the user-space value prior to returning to user space |
| 797 |
#. type: Plain text |
| 798 |
#. #-#-#-#-# opensuse-leap-16-1: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 799 |
#. tglx (July 2015): |
| 800 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 801 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 802 |
#. includes handing over the rtmutex which represents the futex in the |
| 803 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 804 |
#. owner must be the same, except for the update period which is |
| 805 |
#. serialized by the futex internal locking. That means the kernel must |
| 806 |
#. update the user-space value prior to returning to user space |
| 807 |
#. type: Plain text |
| 808 |
#. #-#-#-#-# opensuse-tumbleweed: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 809 |
#. tglx (July 2015): |
| 810 |
#. If there are multiple waiters on a pi futex then a wake pi operation |
| 811 |
#. will wake the first waiter and hand over the lock to this waiter. This |
| 812 |
#. includes handing over the rtmutex which represents the futex in the |
| 813 |
#. kernel. The strict requirement is that the futex owner and the rtmutex |
| 814 |
#. owner must be the same, except for the update period which is |
| 815 |
#. serialized by the futex internal locking. That means the kernel must |
| 816 |
#. update the user-space value prior to returning to user space |
| 817 |
#. type: Plain text |
| 818 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 819 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 820 |
msgid "" |
| 821 |
"It is important to note that the kernel will update the futex word's value " |
| 822 |
"prior to returning to user space. (This prevents the possibility of the " |
| 823 |
"futex word's value ending up in an invalid state, such as having an owner " |
| 824 |
"but the value being 0, or having waiters but not having the B<FUTEX_WAITERS> " |
| 825 |
"bit set.)" |
| 826 |
msgstr "" |
| 827 |
|
| 828 |
#. #-#-#-#-# archlinux: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 829 |
#. tglx (July 2015): |
| 830 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 831 |
#. the kernel has no state associated. This happens via the robust futex |
| 832 |
#. mechanism. In that case the futex value will be set to |
| 833 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 834 |
#. PI futexes. |
| 835 |
#. type: Plain text |
| 836 |
#. #-#-#-#-# debian-trixie: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 837 |
#. tglx (July 2015): |
| 838 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 839 |
#. the kernel has no state associated. This happens via the robust futex |
| 840 |
#. mechanism. In that case the futex value will be set to |
| 841 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 842 |
#. PI futexes. |
| 843 |
#. type: Plain text |
| 844 |
#. #-#-#-#-# debian-unstable: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 845 |
#. tglx (July 2015): |
| 846 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 847 |
#. the kernel has no state associated. This happens via the robust futex |
| 848 |
#. mechanism. In that case the futex value will be set to |
| 849 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 850 |
#. PI futexes. |
| 851 |
#. type: Plain text |
| 852 |
#. #-#-#-#-# fedora-44: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 853 |
#. tglx (July 2015): |
| 854 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 855 |
#. the kernel has no state associated. This happens via the robust futex |
| 856 |
#. mechanism. In that case the futex value will be set to |
| 857 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 858 |
#. PI futexes. |
| 859 |
#. type: Plain text |
| 860 |
#. #-#-#-#-# fedora-rawhide: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 861 |
#. tglx (July 2015): |
| 862 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 863 |
#. the kernel has no state associated. This happens via the robust futex |
| 864 |
#. mechanism. In that case the futex value will be set to |
| 865 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 866 |
#. PI futexes. |
| 867 |
#. type: Plain text |
| 868 |
#. #-#-#-#-# mageia-cauldron: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 869 |
#. tglx (July 2015): |
| 870 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 871 |
#. the kernel has no state associated. This happens via the robust futex |
| 872 |
#. mechanism. In that case the futex value will be set to |
| 873 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 874 |
#. PI futexes. |
| 875 |
#. type: Plain text |
| 876 |
#. #-#-#-#-# opensuse-leap-16-1: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 877 |
#. tglx (July 2015): |
| 878 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 879 |
#. the kernel has no state associated. This happens via the robust futex |
| 880 |
#. mechanism. In that case the futex value will be set to |
| 881 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 882 |
#. PI futexes. |
| 883 |
#. type: Plain text |
| 884 |
#. #-#-#-#-# opensuse-tumbleweed: futex.2.pot (PACKAGE VERSION) #-#-#-#-# |
| 885 |
#. tglx (July 2015): |
| 886 |
#. The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where |
| 887 |
#. the kernel has no state associated. This happens via the robust futex |
| 888 |
#. mechanism. In that case the futex value will be set to |
| 889 |
#. FUTEX_OWNER_DIED. The robust futex mechanism is also available for non |
| 890 |
#. PI futexes. |
| 891 |
#. type: Plain text |
| 892 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 893 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 894 |
msgid "" |
| 895 |
"If a futex has an associated RT-mutex in the kernel (i.e., there are blocked " |
| 896 |
"waiters) and the owner of the futex/RT-mutex dies unexpectedly, then the " |
| 897 |
"kernel cleans up the RT-mutex and hands it over to the next waiter. This in " |
| 898 |
"turn requires that the user-space value is updated accordingly. To indicate " |
| 899 |
"that this is required, the kernel sets the B<FUTEX_OWNER_DIED> bit in the " |
| 900 |
"futex word along with the thread ID of the new owner. User space can detect " |
| 901 |
"this situation via the presence of the B<FUTEX_OWNER_DIED> bit and is then " |
| 902 |
"responsible for cleaning up the stale state left over by the dead owner." |
| 903 |
msgstr "" |
| 904 |
|
| 905 |
#. type: Plain text |
| 906 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 907 |
#: opensuse-tumbleweed |
| 908 |
msgid "" |
| 909 |
"PI futexes are operated on by specifying one of the values listed below in " |
| 910 |
"I<op>. Note that the PI futex operations must be used as paired operations " |
| 911 |
"and are subject to some additional requirements:" |
| 912 |
msgstr "" |
| 913 |
|
| 914 |
#. type: Plain text |
| 915 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 916 |
#: opensuse-tumbleweed |
| 917 |
msgid "" |
| 918 |
"B<FUTEX_LOCK_PI>(2const), B<FUTEX_LOCK_PI2>(2const), and " |
| 919 |
"B<FUTEX_TRYLOCK_PI>(2const) pair with B<FUTEX_UNLOCK_PI>(2const). " |
| 920 |
"B<FUTEX_UNLOCK_PI>(2const) must be called only on a futex owned by the " |
| 921 |
"calling thread, as defined by the value policy, otherwise the error B<EPERM> " |
| 922 |
"results." |
| 923 |
msgstr "" |
| 924 |
|
| 925 |
#. type: Plain text |
| 926 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 927 |
#: opensuse-tumbleweed |
| 928 |
msgid "" |
| 929 |
"B<FUTEX_WAIT_REQUEUE_PI>(2const) pairs with " |
| 930 |
"B<FUTEX_CMP_REQUEUE_PI>(2const). This must be performed from a non-PI futex " |
| 931 |
"to a distinct PI futex (or the error B<EINVAL> results). Additionally, the " |
| 932 |
"number of waiters to be woken must be 1 (or the error B<EINVAL> results)." |
| 933 |
msgstr "" |
| 934 |
|
| 935 |
# |
| 936 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 937 |
#. type: Plain text |
| 938 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 939 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 940 |
msgid "The PI futex operations are as follows:" |
| 941 |
msgstr "" |
| 942 |
|
| 943 |
#. type: TP |
| 944 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 945 |
#: opensuse-tumbleweed |
| 946 |
#, no-wrap |
| 947 |
msgid "B<FUTEX_LOCK_PI>(2const)" |
| 948 |
msgstr "" |
| 949 |
|
| 950 |
#. type: TQ |
| 951 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 952 |
#: opensuse-tumbleweed |
| 953 |
#, no-wrap |
| 954 |
msgid "B<FUTEX_LOCK_PI2>(2const)" |
| 955 |
msgstr "" |
| 956 |
|
| 957 |
#. type: TQ |
| 958 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 959 |
#: opensuse-tumbleweed |
| 960 |
#, no-wrap |
| 961 |
msgid "B<FUTEX_TRYLOCK_PI>(2const)" |
| 962 |
msgstr "" |
| 963 |
|
| 964 |
#. type: TQ |
| 965 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 966 |
#: opensuse-tumbleweed |
| 967 |
#, no-wrap |
| 968 |
msgid "B<FUTEX_UNLOCK_PI>(2const)" |
| 969 |
msgstr "" |
| 970 |
|
| 971 |
#. type: TQ |
| 972 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 973 |
#: opensuse-tumbleweed |
| 974 |
#, no-wrap |
| 975 |
msgid "B<FUTEX_CMP_REQUEUE_PI>(2const)" |
| 976 |
msgstr "" |
| 977 |
|
| 978 |
#. type: TQ |
| 979 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 980 |
#: opensuse-tumbleweed |
| 981 |
#, no-wrap |
| 982 |
msgid "B<FUTEX_WAIT_REQUEUE_PI>(2const)" |
| 983 |
msgstr "" |
| 984 |
|
| 985 |
# |
| 986 |
# |
| 987 |
# |
| 988 |
# |
| 989 |
# |
| 990 |
#. Darren Hart notes that a patch to allow glibc to fully support |
| 991 |
#. PI-aware pthreads condition variables has not yet been accepted into |
| 992 |
#. glibc. The story is complex, and can be found at |
| 993 |
#. https://sourceware.org/bugzilla/show_bug.cgi?id=11588 |
| 994 |
#. Darren notes that in the meantime, the patch is shipped with various |
| 995 |
#. PREEMPT_RT-enabled Linux systems. |
| 996 |
#. Related to the preceding, Darren proposed that somewhere, man-pages |
| 997 |
#. should document the following point: |
| 998 |
#. While the Linux kernel, since Linux 2.6.31, supports requeueing of |
| 999 |
#. priority-inheritance (PI) aware mutexes via the |
| 1000 |
#. FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI futex operations, |
| 1001 |
#. the glibc implementation does not yet take full advantage of this. |
| 1002 |
#. Specifically, the condvar internal data lock remains a non-PI aware |
| 1003 |
#. mutex, regardless of the type of the pthread_mutex associated with |
| 1004 |
#. the condvar. This can lead to an unbounded priority inversion on |
| 1005 |
#. the internal data lock even when associating a PI aware |
| 1006 |
#. pthread_mutex with a condvar during a pthread_cond*_wait |
| 1007 |
#. operation. For this reason, it is not recommended to rely on |
| 1008 |
#. priority inheritance when using pthread condition variables. |
| 1009 |
#. The problem is that the obvious location for this text is |
| 1010 |
#. the pthread_cond*wait(3) man page. However, such a man page |
| 1011 |
#. does not currently exist. |
| 1012 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1013 |
#. type: Plain text |
| 1014 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1015 |
#: opensuse-tumbleweed |
| 1016 |
msgid "" |
| 1017 |
"The B<FUTEX_WAIT_REQUEUE_PI>(2const) and B<FUTEX_CMP_REQUEUE_PI>(2const) " |
| 1018 |
"were added to support a fairly specific use case: support for priority-" |
| 1019 |
"inheritance-aware POSIX threads condition variables. The idea is that these " |
| 1020 |
"operations should always be paired, in order to ensure that user space and " |
| 1021 |
"the kernel remain in sync. Thus, in the B<FUTEX_WAIT_REQUEUE_PI>(2const) " |
| 1022 |
"operation, the user-space application pre-specifies the target of the " |
| 1023 |
"requeue that takes place in the B<FUTEX_CMP_REQUEUE_PI>(2const) operation." |
| 1024 |
msgstr "" |
| 1025 |
|
| 1026 |
#. type: SH |
| 1027 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1028 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1029 |
#, no-wrap |
| 1030 |
msgid "RETURN VALUE" |
| 1031 |
msgstr "" |
| 1032 |
|
| 1033 |
#. type: Plain text |
| 1034 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1035 |
#: opensuse-tumbleweed |
| 1036 |
msgid "On error, -1 is returned, and I<errno> is set to indicate the error." |
| 1037 |
msgstr "" |
| 1038 |
|
| 1039 |
# |
| 1040 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1041 |
#. type: Plain text |
| 1042 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1043 |
#: opensuse-tumbleweed |
| 1044 |
msgid "The return value on success depends on the operation." |
| 1045 |
msgstr "" |
| 1046 |
|
| 1047 |
#. type: SH |
| 1048 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1049 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1050 |
#, no-wrap |
| 1051 |
msgid "ERRORS" |
| 1052 |
msgstr "" |
| 1053 |
|
| 1054 |
#. type: TP |
| 1055 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1056 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1057 |
#, no-wrap |
| 1058 |
msgid "B<EACCES>" |
| 1059 |
msgstr "" |
| 1060 |
|
| 1061 |
#. type: Plain text |
| 1062 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1063 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1064 |
msgid "No read access to the memory of a futex word." |
| 1065 |
msgstr "" |
| 1066 |
|
| 1067 |
#. type: TP |
| 1068 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1069 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1070 |
#, no-wrap |
| 1071 |
msgid "B<EFAULT>" |
| 1072 |
msgstr "" |
| 1073 |
|
| 1074 |
#. type: Plain text |
| 1075 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1076 |
#: opensuse-tumbleweed |
| 1077 |
msgid "I<uaddr> did not point to a valid user-space address." |
| 1078 |
msgstr "" |
| 1079 |
|
| 1080 |
#. type: TP |
| 1081 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1082 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1083 |
#, no-wrap |
| 1084 |
msgid "B<EINVAL>" |
| 1085 |
msgstr "" |
| 1086 |
|
| 1087 |
#. type: Plain text |
| 1088 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1089 |
#: opensuse-tumbleweed |
| 1090 |
msgid "" |
| 1091 |
"I<uaddr> does not point to a valid object\\[em]that is, the address is not " |
| 1092 |
"four-byte-aligned." |
| 1093 |
msgstr "" |
| 1094 |
|
| 1095 |
#. type: Plain text |
| 1096 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1097 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1098 |
msgid "Invalid argument." |
| 1099 |
msgstr "" |
| 1100 |
|
| 1101 |
#. type: TP |
| 1102 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1103 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1104 |
#, no-wrap |
| 1105 |
msgid "B<ENOSYS>" |
| 1106 |
msgstr "" |
| 1107 |
|
| 1108 |
#. type: Plain text |
| 1109 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1110 |
#: opensuse-tumbleweed |
| 1111 |
msgid "Invalid operation specified in I<op>." |
| 1112 |
msgstr "" |
| 1113 |
|
| 1114 |
# |
| 1115 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1116 |
#. type: Plain text |
| 1117 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1118 |
#: opensuse-tumbleweed |
| 1119 |
msgid "" |
| 1120 |
"The B<FUTEX_CLOCK_REALTIME> option was specified in I<op>, but the " |
| 1121 |
"accompanying operation was neither B<FUTEX_WAIT_BITSET>(2const), " |
| 1122 |
"B<FUTEX_WAIT_REQUEUE_PI>(2const), nor B<FUTEX_LOCK_PI2>(2const)." |
| 1123 |
msgstr "" |
| 1124 |
|
| 1125 |
#. type: SH |
| 1126 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1127 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1128 |
#, no-wrap |
| 1129 |
msgid "STANDARDS" |
| 1130 |
msgstr "" |
| 1131 |
|
| 1132 |
#. type: Plain text |
| 1133 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1134 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1135 |
msgid "Linux." |
| 1136 |
msgstr "" |
| 1137 |
|
| 1138 |
#. type: SH |
| 1139 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1140 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1141 |
#, no-wrap |
| 1142 |
msgid "HISTORY" |
| 1143 |
msgstr "" |
| 1144 |
|
| 1145 |
#. type: Plain text |
| 1146 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1147 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1148 |
msgid "Linux 2.6.0." |
| 1149 |
msgstr "" |
| 1150 |
|
| 1151 |
#. type: Plain text |
| 1152 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1153 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1154 |
msgid "" |
| 1155 |
"Initial futex support was merged in Linux 2.5.7 but with different semantics " |
| 1156 |
"from what was described above. A four-argument system call with the " |
| 1157 |
"semantics described in this page was introduced in Linux 2.5.40. A fifth " |
| 1158 |
"argument was added in Linux 2.5.70, and a sixth argument was added in Linux " |
| 1159 |
"2.6.7." |
| 1160 |
msgstr "" |
| 1161 |
|
| 1162 |
#. type: SH |
| 1163 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1164 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1165 |
#, no-wrap |
| 1166 |
msgid "EXAMPLES" |
| 1167 |
msgstr "" |
| 1168 |
|
| 1169 |
#. type: Plain text |
| 1170 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1171 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1172 |
msgid "" |
| 1173 |
"The program below demonstrates use of futexes in a program where a parent " |
| 1174 |
"process and a child process use a pair of futexes located inside a shared " |
| 1175 |
"anonymous mapping to synchronize access to a shared resource: the terminal. " |
| 1176 |
"The two processes each write I<nloops> (a command-line argument that " |
| 1177 |
"defaults to 5 if omitted) messages to the terminal and employ a " |
| 1178 |
"synchronization protocol that ensures that they alternate in writing " |
| 1179 |
"messages. Upon running this program we see output such as the following:" |
| 1180 |
msgstr "" |
| 1181 |
|
| 1182 |
#. type: Plain text |
| 1183 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1184 |
#: opensuse-tumbleweed |
| 1185 |
#, no-wrap |
| 1186 |
msgid "" |
| 1187 |
"$B< ./futex_demo>;\n" |
| 1188 |
"Parent (18534) 0\n" |
| 1189 |
"Child (18535) 0\n" |
| 1190 |
"Parent (18534) 1\n" |
| 1191 |
"Child (18535) 1\n" |
| 1192 |
"Parent (18534) 2\n" |
| 1193 |
"Child (18535) 2\n" |
| 1194 |
"Parent (18534) 3\n" |
| 1195 |
"Child (18535) 3\n" |
| 1196 |
"Parent (18534) 4\n" |
| 1197 |
"Child (18535) 4\n" |
| 1198 |
msgstr "" |
| 1199 |
|
| 1200 |
#. type: SS |
| 1201 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1202 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1203 |
#, no-wrap |
| 1204 |
msgid "Program source" |
| 1205 |
msgstr "" |
| 1206 |
|
| 1207 |
#. type: Plain text |
| 1208 |
#: archlinux debian-unstable opensuse-leap-16-1 opensuse-tumbleweed |
| 1209 |
#, no-wrap |
| 1210 |
msgid "" |
| 1211 |
"/* futex_demo.c\n" |
| 1212 |
"\\&\n" |
| 1213 |
" Usage: futex_demo [nloops]\n" |
| 1214 |
" (Default: 5)\n" |
| 1215 |
"\\&\n" |
| 1216 |
" Demonstrate the use of futexes in a program where parent and child\n" |
| 1217 |
" use a pair of futexes located inside a shared anonymous mapping to\n" |
| 1218 |
" synchronize access to a shared resource: the terminal. The two\n" |
| 1219 |
" processes each write \\[aq]num-loops\\[aq] messages to the terminal and employ\n" |
| 1220 |
" a synchronization protocol that ensures that they alternate in\n" |
| 1221 |
" writing messages.\n" |
| 1222 |
"*/\n" |
| 1223 |
"#define _GNU_SOURCE\n" |
| 1224 |
"#include E<lt>err.hE<gt>\n" |
| 1225 |
"#include E<lt>errno.hE<gt>\n" |
| 1226 |
"#include E<lt>linux/futex.hE<gt>\n" |
| 1227 |
"#include E<lt>stdatomic.hE<gt>\n" |
| 1228 |
"#include E<lt>stdint.hE<gt>\n" |
| 1229 |
"#include E<lt>stdio.hE<gt>\n" |
| 1230 |
"#include E<lt>stdlib.hE<gt>\n" |
| 1231 |
"#include E<lt>sys/mman.hE<gt>\n" |
| 1232 |
"#include E<lt>sys/syscall.hE<gt>\n" |
| 1233 |
"#include E<lt>sys/time.hE<gt>\n" |
| 1234 |
"#include E<lt>sys/wait.hE<gt>\n" |
| 1235 |
"#include E<lt>unistd.hE<gt>\n" |
| 1236 |
"\\&\n" |
| 1237 |
"static uint32_t *futex1, *futex2, *iaddr;\n" |
| 1238 |
"\\&\n" |
| 1239 |
"static int\n" |
| 1240 |
"futex(uint32_t *uaddr, int op, uint32_t val,\n" |
| 1241 |
" const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3)\n" |
| 1242 |
"{\n" |
| 1243 |
" return syscall(SYS_futex, uaddr, op, val,\n" |
| 1244 |
" timeout, uaddr2, val3);\n" |
| 1245 |
"}\n" |
| 1246 |
"\\&\n" |
| 1247 |
"/* Acquire the futex pointed to by \\[aq]futexp\\[aq]: wait for its value to\n" |
| 1248 |
" become 1, and then set the value to 0. */\n" |
| 1249 |
"\\&\n" |
| 1250 |
"static void\n" |
| 1251 |
"fwait(uint32_t *futexp)\n" |
| 1252 |
"{\n" |
| 1253 |
" long s;\n" |
| 1254 |
" const uint32_t one = 1;\n" |
| 1255 |
"\\&\n" |
| 1256 |
" /* atomic_compare_exchange_strong(ptr, oldval, newval)\n" |
| 1257 |
" atomically performs the equivalent of:\n" |
| 1258 |
"\\&\n" |
| 1259 |
" if (*ptr == *oldval)\n" |
| 1260 |
" *ptr = newval;\n" |
| 1261 |
"\\&\n" |
| 1262 |
" It returns true if the test yielded true and *ptr was updated. */\n" |
| 1263 |
"\\&\n" |
| 1264 |
" for (;;) {\n" |
| 1265 |
"\\&\n" |
| 1266 |
" /* Is the futex available? */\n" |
| 1267 |
" if (atomic_compare_exchange_strong(futexp, &one, 0))\n" |
| 1268 |
" break; /* Yes */\n" |
| 1269 |
"\\&\n" |
| 1270 |
" /* Futex is not available; wait. */\n" |
| 1271 |
"\\&\n" |
| 1272 |
" s = futex(futexp, FUTEX_WAIT, 0, NULL, NULL, 0);\n" |
| 1273 |
" if (s == -1 && errno != EAGAIN)\n" |
| 1274 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAIT\");\n" |
| 1275 |
" }\n" |
| 1276 |
"}\n" |
| 1277 |
"\\&\n" |
| 1278 |
"/* Release the futex pointed to by \\[aq]futexp\\[aq]: if the futex currently\n" |
| 1279 |
" has the value 0, set its value to 1 and then wake any futex waiters,\n" |
| 1280 |
" so that if the peer is blocked in fwait(), it can proceed. */\n" |
| 1281 |
"\\&\n" |
| 1282 |
"static void\n" |
| 1283 |
"fpost(uint32_t *futexp)\n" |
| 1284 |
"{\n" |
| 1285 |
" long s;\n" |
| 1286 |
" const uint32_t zero = 0;\n" |
| 1287 |
"\\&\n" |
| 1288 |
" /* atomic_compare_exchange_strong() was described\n" |
| 1289 |
" in comments above. */\n" |
| 1290 |
"\\&\n" |
| 1291 |
" if (atomic_compare_exchange_strong(futexp, &zero, 1)) {\n" |
| 1292 |
" s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);\n" |
| 1293 |
" if (s == -1)\n" |
| 1294 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAKE\");\n" |
| 1295 |
" }\n" |
| 1296 |
"}\n" |
| 1297 |
"\\&\n" |
| 1298 |
"int\n" |
| 1299 |
"main(int argc, char *argv[])\n" |
| 1300 |
"{\n" |
| 1301 |
" pid_t childPid;\n" |
| 1302 |
" unsigned int nloops;\n" |
| 1303 |
"\\&\n" |
| 1304 |
" setbuf(stdout, NULL);\n" |
| 1305 |
"\\&\n" |
| 1306 |
" nloops = (argc E<gt> 1) ? atoi(argv[1]) : 5;\n" |
| 1307 |
"\\&\n" |
| 1308 |
" /* Create a shared anonymous mapping that will hold the futexes.\n" |
| 1309 |
" Since the futexes are being shared between processes, we\n" |
| 1310 |
" subsequently use the \"shared\" futex operations (i.e., not the\n" |
| 1311 |
" ones suffixed \"_PRIVATE\"). */\n" |
| 1312 |
"\\&\n" |
| 1313 |
" iaddr = mmap(NULL, sizeof(*iaddr) * 2, PROT_READ | PROT_WRITE,\n" |
| 1314 |
" MAP_ANONYMOUS | MAP_SHARED, -1, 0);\n" |
| 1315 |
" if (iaddr == MAP_FAILED)\n" |
| 1316 |
" err(EXIT_FAILURE, \"mmap\");\n" |
| 1317 |
"\\&\n" |
| 1318 |
" futex1 = &iaddr[0];\n" |
| 1319 |
" futex2 = &iaddr[1];\n" |
| 1320 |
"\\&\n" |
| 1321 |
" *futex1 = 0; /* State: unavailable */\n" |
| 1322 |
" *futex2 = 1; /* State: available */\n" |
| 1323 |
"\\&\n" |
| 1324 |
" /* Create a child process that inherits the shared anonymous\n" |
| 1325 |
" mapping. */\n" |
| 1326 |
"\\&\n" |
| 1327 |
" childPid = fork();\n" |
| 1328 |
" if (childPid == -1)\n" |
| 1329 |
" err(EXIT_FAILURE, \"fork\");\n" |
| 1330 |
"\\&\n" |
| 1331 |
" if (childPid == 0) { /* Child */\n" |
| 1332 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 1333 |
" fwait(futex1);\n" |
| 1334 |
" printf(\"Child (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 1335 |
" fpost(futex2);\n" |
| 1336 |
" }\n" |
| 1337 |
"\\&\n" |
| 1338 |
" exit(EXIT_SUCCESS);\n" |
| 1339 |
" }\n" |
| 1340 |
"\\&\n" |
| 1341 |
" /* Parent falls through to here. */\n" |
| 1342 |
"\\&\n" |
| 1343 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 1344 |
" fwait(futex2);\n" |
| 1345 |
" printf(\"Parent (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 1346 |
" fpost(futex1);\n" |
| 1347 |
" }\n" |
| 1348 |
"\\&\n" |
| 1349 |
" wait(NULL);\n" |
| 1350 |
"\\&\n" |
| 1351 |
" exit(EXIT_SUCCESS);\n" |
| 1352 |
"}\n" |
| 1353 |
msgstr "" |
| 1354 |
|
| 1355 |
#. SRC END |
| 1356 |
#. type: SH |
| 1357 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1358 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1359 |
#, no-wrap |
| 1360 |
msgid "SEE ALSO" |
| 1361 |
msgstr "" |
| 1362 |
|
| 1363 |
#. type: Plain text |
| 1364 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1365 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1366 |
msgid "" |
| 1367 |
"B<get_robust_list>(2), B<restart_syscall>(2), " |
| 1368 |
"B<pthread_mutexattr_getprotocol>(3), B<futex>(7), B<sched>(7)" |
| 1369 |
msgstr "" |
| 1370 |
|
| 1371 |
#. type: Plain text |
| 1372 |
#: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide |
| 1373 |
#: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed |
| 1374 |
msgid "The following kernel source files:" |
| 1375 |
msgstr "" |
| 1376 |
|
| 1377 |
#. type: Plain text |
| 1378 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1379 |
#: opensuse-tumbleweed |
| 1380 |
msgid "I<Documentation/locking/pi-futex.rst>" |
| 1381 |
msgstr "" |
| 1382 |
|
| 1383 |
#. type: Plain text |
| 1384 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1385 |
#: opensuse-tumbleweed |
| 1386 |
msgid "I<Documentation/locking/futex-requeue-pi.rst>" |
| 1387 |
msgstr "" |
| 1388 |
|
| 1389 |
#. type: Plain text |
| 1390 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1391 |
#: opensuse-tumbleweed |
| 1392 |
msgid "I<Documentation/locking/rt-mutex.rst>" |
| 1393 |
msgstr "" |
| 1394 |
|
| 1395 |
#. type: Plain text |
| 1396 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1397 |
#: opensuse-tumbleweed |
| 1398 |
msgid "I<Documentation/locking/rt-mutex-design.rst>" |
| 1399 |
msgstr "" |
| 1400 |
|
| 1401 |
#. type: Plain text |
| 1402 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1403 |
#: opensuse-tumbleweed |
| 1404 |
msgid "I<Documentation/robust-futex-ABI.rst>" |
| 1405 |
msgstr "" |
| 1406 |
|
| 1407 |
#. type: Plain text |
| 1408 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1409 |
#: opensuse-tumbleweed |
| 1410 |
msgid "Franke, H., Russell, R., and Kirwood, M., 2002." |
| 1411 |
msgstr "" |
| 1412 |
|
| 1413 |
#. type: Plain text |
| 1414 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1415 |
#: opensuse-tumbleweed |
| 1416 |
msgid "" |
| 1417 |
"E<.UR http:\\://kernel.org/\\:doc/\\:ols/\\:2002/\\:ols2002-" |
| 1418 |
"pages-479-495.pdf> I<Fuss, Futexes and Furwocks: Fast Userlevel Locking in " |
| 1419 |
"Linux> E<.UE> (from proceedings of the Ottawa Linux Symposium 2002)." |
| 1420 |
msgstr "" |
| 1421 |
|
| 1422 |
#. type: Plain text |
| 1423 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1424 |
#: opensuse-tumbleweed |
| 1425 |
msgid "" |
| 1426 |
"Hart, D., 2009. E<.UR http:\\://lwn.net/\\:Articles/\\:360699/> I<A futex " |
| 1427 |
"overview and update> E<.UE .>" |
| 1428 |
msgstr "" |
| 1429 |
|
| 1430 |
#. type: Plain text |
| 1431 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1432 |
#: opensuse-tumbleweed |
| 1433 |
msgid "" |
| 1434 |
"Hart, D.\\& and Guniguntala, D., 2009. E<.UR http:\\://lwn.net/\\:images/" |
| 1435 |
"\\:conf/\\:rtlws11/\\:papers/\\:proc/\\:p10.pdf> I<Requeue-PI: Making glibc " |
| 1436 |
"Condvars PI-Aware> E<.UE> (from proceedings of the 2009 Real-Time Linux " |
| 1437 |
"Workshop)." |
| 1438 |
msgstr "" |
| 1439 |
|
| 1440 |
#. type: Plain text |
| 1441 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1442 |
#: opensuse-tumbleweed |
| 1443 |
msgid "" |
| 1444 |
"Drepper, U., 2011. E<.UR http:\\://www.akkadia.org/\\:drepper/\\:futex.pdf> " |
| 1445 |
"I<Futexes Are Tricky> E<.UE .>" |
| 1446 |
msgstr "" |
| 1447 |
|
| 1448 |
#. type: Plain text |
| 1449 |
#: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 |
| 1450 |
#: opensuse-tumbleweed |
| 1451 |
msgid "" |
| 1452 |
"Futex example library, E<.UR https:\\://mirrors.kernel.org/\\:pub/\\:linux/" |
| 1453 |
"\\:kernel/\\:people/\\:rusty/> futex-*.tar.bz2 E<.UE .>" |
| 1454 |
msgstr "" |
| 1455 |
|
| 1456 |
#. type: TH |
| 1457 |
#: debian-trixie |
| 1458 |
#, no-wrap |
| 1459 |
msgid "2024-06-15" |
| 1460 |
msgstr "" |
| 1461 |
|
| 1462 |
#. type: TH |
| 1463 |
#: debian-trixie |
| 1464 |
#, no-wrap |
| 1465 |
msgid "Linux man-pages 6.9.1" |
| 1466 |
msgstr "" |
| 1467 |
|
| 1468 |
#. type: Plain text |
| 1469 |
#: debian-trixie |
| 1470 |
msgid "Standard C library (I<libc>, I<-lc>)" |
| 1471 |
msgstr "" |
| 1472 |
|
| 1473 |
#. type: Plain text |
| 1474 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1475 |
#, no-wrap |
| 1476 |
msgid "" |
| 1477 |
"B<#include E<lt>linux/futex.hE<gt>> /* Definition of B<FUTEX_*> constants */\n" |
| 1478 |
"B<#include E<lt>sys/syscall.hE<gt>> /* Definition of B<SYS_*> constants */\n" |
| 1479 |
"B<#include E<lt>unistd.hE<gt>>\n" |
| 1480 |
msgstr "" |
| 1481 |
|
| 1482 |
#. type: Plain text |
| 1483 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1484 |
#, no-wrap |
| 1485 |
msgid "" |
| 1486 |
"B<long syscall(SYS_futex, uint32_t *>I<uaddr>B<, int >I<futex_op>B<, uint32_t >I<val>B<,>\n" |
| 1487 |
"B< const struct timespec *>I<timeout>B<,>I< > /* or: B<uint32_t >I<val2>B< */>\n" |
| 1488 |
"B< uint32_t *>I<uaddr2>B<, uint32_t >I<val3>B<);>\n" |
| 1489 |
msgstr "" |
| 1490 |
|
| 1491 |
#. type: Plain text |
| 1492 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1493 |
msgid "" |
| 1494 |
"I<Note>: glibc provides no wrapper for B<futex>(), necessitating the use of " |
| 1495 |
"B<syscall>(2)." |
| 1496 |
msgstr "" |
| 1497 |
|
| 1498 |
#. type: Plain text |
| 1499 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1500 |
msgid "" |
| 1501 |
"Note that no explicit initialization or destruction is necessary to use " |
| 1502 |
"futexes; the kernel maintains a futex (i.e., the kernel-internal " |
| 1503 |
"implementation artifact) only while operations such as B<FUTEX_WAIT>, " |
| 1504 |
"described below, are being performed on a particular futex word." |
| 1505 |
msgstr "" |
| 1506 |
|
| 1507 |
#. type: Plain text |
| 1508 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1509 |
msgid "" |
| 1510 |
"The I<uaddr> argument points to the futex word. On all platforms, futexes " |
| 1511 |
"are four-byte integers that must be aligned on a four-byte boundary. The " |
| 1512 |
"operation to perform on the futex is specified in the I<futex_op> argument; " |
| 1513 |
"I<val> is a value whose meaning and purpose depends on I<futex_op>." |
| 1514 |
msgstr "" |
| 1515 |
|
| 1516 |
#. type: Plain text |
| 1517 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1518 |
msgid "" |
| 1519 |
"The remaining arguments (I<timeout>, I<uaddr2>, and I<val3>) are required " |
| 1520 |
"only for certain of the futex operations described below. Where one of " |
| 1521 |
"these arguments is not required, it is ignored." |
| 1522 |
msgstr "" |
| 1523 |
|
| 1524 |
#. type: Plain text |
| 1525 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1526 |
msgid "" |
| 1527 |
"For several blocking operations, the I<timeout> argument is a pointer to a " |
| 1528 |
"I<timespec> structure that specifies a timeout for the operation. However, " |
| 1529 |
"notwithstanding the prototype shown above, for some operations, the least " |
| 1530 |
"significant four bytes of this argument are instead used as an integer whose " |
| 1531 |
"meaning is determined by the operation. For these operations, the kernel " |
| 1532 |
"casts the I<timeout> value first to I<unsigned long>, then to I<uint32_t>, " |
| 1533 |
"and in the remainder of this page, this argument is referred to as I<val2> " |
| 1534 |
"when interpreted in this fashion." |
| 1535 |
msgstr "" |
| 1536 |
|
| 1537 |
#. type: Plain text |
| 1538 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1539 |
msgid "" |
| 1540 |
"Where it is required, the I<uaddr2> argument is a pointer to a second futex " |
| 1541 |
"word that is employed by the operation." |
| 1542 |
msgstr "" |
| 1543 |
|
| 1544 |
# |
| 1545 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1546 |
#. type: Plain text |
| 1547 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1548 |
msgid "" |
| 1549 |
"The interpretation of the final integer argument, I<val3>, depends on the " |
| 1550 |
"operation." |
| 1551 |
msgstr "" |
| 1552 |
|
| 1553 |
#. type: Plain text |
| 1554 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1555 |
msgid "" |
| 1556 |
"The I<futex_op> argument consists of two parts: a command that specifies the " |
| 1557 |
"operation to be performed, bitwise ORed with zero or more options that " |
| 1558 |
"modify the behaviour of the operation. The options that may be included in " |
| 1559 |
"I<futex_op> are as follows:" |
| 1560 |
msgstr "" |
| 1561 |
|
| 1562 |
#. commit 1acdac104668a0834cfa267de9946fac7764d486 |
| 1563 |
#. commit 337f13046ff03717a9e99675284a817527440a49 |
| 1564 |
#. commit bf22a6976897977b0a3f1aeba6823c959fc4fdae |
| 1565 |
#. type: Plain text |
| 1566 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1567 |
msgid "" |
| 1568 |
"This option bit can be employed only with the B<FUTEX_WAIT_BITSET>, " |
| 1569 |
"B<FUTEX_WAIT_REQUEUE_PI>, (since Linux 4.5) B<FUTEX_WAIT>, and (since Linux " |
| 1570 |
"5.14) B<FUTEX_LOCK_PI2> operations." |
| 1571 |
msgstr "" |
| 1572 |
|
| 1573 |
# |
| 1574 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1575 |
#. type: Plain text |
| 1576 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1577 |
msgid "The operation specified in I<futex_op> is one of the following:" |
| 1578 |
msgstr "" |
| 1579 |
|
| 1580 |
#. type: TP |
| 1581 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1582 |
#, no-wrap |
| 1583 |
msgid "B<FUTEX_WAIT> (since Linux 2.6.0)" |
| 1584 |
msgstr "" |
| 1585 |
|
| 1586 |
#. Strictly speaking, since some time in Linux 2.5.x |
| 1587 |
#. FIXME: Torvald, I think we may need to add some explanation of |
| 1588 |
#. "totally ordered" here. |
| 1589 |
#. type: Plain text |
| 1590 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1591 |
msgid "" |
| 1592 |
"This operation tests that the value at the futex word pointed to by the " |
| 1593 |
"address I<uaddr> still contains the expected value I<val>, and if so, then " |
| 1594 |
"sleeps waiting for a B<FUTEX_WAKE> operation on the futex word. The load of " |
| 1595 |
"the value of the futex word is an atomic memory access (i.e., using atomic " |
| 1596 |
"machine instructions of the respective architecture). This load, the " |
| 1597 |
"comparison with the expected value, and starting to sleep are performed " |
| 1598 |
"atomically and totally ordered with respect to other futex operations on the " |
| 1599 |
"same futex word. If the thread starts to sleep, it is considered a waiter " |
| 1600 |
"on this futex word. If the futex value does not match I<val>, then the call " |
| 1601 |
"fails immediately with the error B<EAGAIN>." |
| 1602 |
msgstr "" |
| 1603 |
|
| 1604 |
#. type: Plain text |
| 1605 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1606 |
msgid "" |
| 1607 |
"The purpose of the comparison with the expected value is to prevent lost " |
| 1608 |
"wake-ups. If another thread changed the value of the futex word after the " |
| 1609 |
"calling thread decided to block based on the prior value, and if the other " |
| 1610 |
"thread executed a B<FUTEX_WAKE> operation (or similar wake-up) after the " |
| 1611 |
"value change and before this B<FUTEX_WAIT> operation, then the calling " |
| 1612 |
"thread will observe the value change and will not start to sleep." |
| 1613 |
msgstr "" |
| 1614 |
|
| 1615 |
#. type: Plain text |
| 1616 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1617 |
msgid "" |
| 1618 |
"If the I<timeout> is not NULL, the structure it points to specifies a " |
| 1619 |
"timeout for the wait. (This interval will be rounded up to the system clock " |
| 1620 |
"granularity, and is guaranteed not to expire early.) The timeout is by " |
| 1621 |
"default measured according to the B<CLOCK_MONOTONIC> clock, but, since Linux " |
| 1622 |
"4.5, the B<CLOCK_REALTIME> clock can be selected by specifying " |
| 1623 |
"B<FUTEX_CLOCK_REALTIME> in I<futex_op>. If I<timeout> is NULL, the call " |
| 1624 |
"blocks indefinitely." |
| 1625 |
msgstr "" |
| 1626 |
|
| 1627 |
#. type: Plain text |
| 1628 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1629 |
msgid "" |
| 1630 |
"I<Note>: for B<FUTEX_WAIT>, I<timeout> is interpreted as a I<relative> " |
| 1631 |
"value. This differs from other futex operations, where I<timeout> is " |
| 1632 |
"interpreted as an absolute value. To obtain the equivalent of B<FUTEX_WAIT> " |
| 1633 |
"with an absolute timeout, employ B<FUTEX_WAIT_BITSET> with I<val3> specified " |
| 1634 |
"as B<FUTEX_BITSET_MATCH_ANY>." |
| 1635 |
msgstr "" |
| 1636 |
|
| 1637 |
# |
| 1638 |
# |
| 1639 |
#. FIXME . (Torvald) I think we should remove this. Or maybe adapt to a |
| 1640 |
#. different example. |
| 1641 |
#. For |
| 1642 |
#. .BR futex (7), |
| 1643 |
#. this call is executed if decrementing the count gave a negative value |
| 1644 |
#. (indicating contention), |
| 1645 |
#. and will sleep until another process or thread releases |
| 1646 |
#. the futex and executes the |
| 1647 |
#. .B FUTEX_WAKE |
| 1648 |
#. operation. |
| 1649 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1650 |
#. type: Plain text |
| 1651 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1652 |
msgid "The arguments I<uaddr2> and I<val3> are ignored." |
| 1653 |
msgstr "" |
| 1654 |
|
| 1655 |
#. type: TP |
| 1656 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1657 |
#, no-wrap |
| 1658 |
msgid "B<FUTEX_WAKE> (since Linux 2.6.0)" |
| 1659 |
msgstr "" |
| 1660 |
|
| 1661 |
#. Strictly speaking, since Linux 2.5.x |
| 1662 |
#. type: Plain text |
| 1663 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1664 |
msgid "" |
| 1665 |
"This operation wakes at most I<val> of the waiters that are waiting (e.g., " |
| 1666 |
"inside B<FUTEX_WAIT>) on the futex word at the address I<uaddr>. Most " |
| 1667 |
"commonly, I<val> is specified as either 1 (wake up a single waiter) or " |
| 1668 |
"B<INT_MAX> (wake up all waiters). No guarantee is provided about which " |
| 1669 |
"waiters are awoken (e.g., a waiter with a higher scheduling priority is not " |
| 1670 |
"guaranteed to be awoken in preference to a waiter with a lower priority)." |
| 1671 |
msgstr "" |
| 1672 |
|
| 1673 |
#. type: Plain text |
| 1674 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1675 |
msgid "The arguments I<timeout>, I<uaddr2>, and I<val3> are ignored." |
| 1676 |
msgstr "" |
| 1677 |
|
| 1678 |
#. type: TP |
| 1679 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1680 |
#, no-wrap |
| 1681 |
msgid "B<FUTEX_FD> (from Linux 2.6.0 up to and including Linux 2.6.25)" |
| 1682 |
msgstr "" |
| 1683 |
|
| 1684 |
#. Strictly speaking, from Linux 2.5.x to Linux 2.6.25 |
| 1685 |
#. type: Plain text |
| 1686 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1687 |
msgid "" |
| 1688 |
"This operation creates a file descriptor that is associated with the futex " |
| 1689 |
"at I<uaddr>. The caller must close the returned file descriptor after use. " |
| 1690 |
"When another process or thread performs a B<FUTEX_WAKE> on the futex word, " |
| 1691 |
"the file descriptor indicates as being readable with B<select>(2), " |
| 1692 |
"B<poll>(2), and B<epoll>(7)" |
| 1693 |
msgstr "" |
| 1694 |
|
| 1695 |
#. type: Plain text |
| 1696 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1697 |
msgid "" |
| 1698 |
"The file descriptor can be used to obtain asynchronous notifications: if " |
| 1699 |
"I<val> is nonzero, then, when another process or thread executes a " |
| 1700 |
"B<FUTEX_WAKE>, the caller will receive the signal number that was passed in " |
| 1701 |
"I<val>." |
| 1702 |
msgstr "" |
| 1703 |
|
| 1704 |
# |
| 1705 |
#. commit 82af7aca56c67061420d618cc5a30f0fd4106b80 |
| 1706 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1707 |
#. type: Plain text |
| 1708 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1709 |
msgid "" |
| 1710 |
"Because it was inherently racy, B<FUTEX_FD> has been removed from Linux " |
| 1711 |
"2.6.26 onward." |
| 1712 |
msgstr "" |
| 1713 |
|
| 1714 |
#. type: TP |
| 1715 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1716 |
#, no-wrap |
| 1717 |
msgid "B<FUTEX_REQUEUE> (since Linux 2.6.0)" |
| 1718 |
msgstr "" |
| 1719 |
|
| 1720 |
# |
| 1721 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1722 |
#. type: Plain text |
| 1723 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1724 |
msgid "" |
| 1725 |
"This operation performs the same task as B<FUTEX_CMP_REQUEUE> (see below), " |
| 1726 |
"except that no check is made using the value in I<val3>. (The argument " |
| 1727 |
"I<val3> is ignored.)" |
| 1728 |
msgstr "" |
| 1729 |
|
| 1730 |
#. type: TP |
| 1731 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1732 |
#, no-wrap |
| 1733 |
msgid "B<FUTEX_CMP_REQUEUE> (since Linux 2.6.7)" |
| 1734 |
msgstr "" |
| 1735 |
|
| 1736 |
#. type: Plain text |
| 1737 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1738 |
msgid "" |
| 1739 |
"This operation first checks whether the location I<uaddr> still contains the " |
| 1740 |
"value I<val3>. If not, the operation fails with the error B<EAGAIN>. " |
| 1741 |
"Otherwise, the operation wakes up a maximum of I<val> waiters that are " |
| 1742 |
"waiting on the futex at I<uaddr>. If there are more than I<val> waiters, " |
| 1743 |
"then the remaining waiters are removed from the wait queue of the source " |
| 1744 |
"futex at I<uaddr> and added to the wait queue of the target futex at " |
| 1745 |
"I<uaddr2>. The I<val2> argument specifies an upper limit on the number of " |
| 1746 |
"waiters that are requeued to the futex at I<uaddr2>." |
| 1747 |
msgstr "" |
| 1748 |
|
| 1749 |
#. FIXME(Torvald) Is the following correct? Or is just the decision |
| 1750 |
#. which threads to wake or requeue part of the atomic operation? |
| 1751 |
#. Notes from a f2f conversation with Thomas Gleixner (Aug 2015): ### |
| 1752 |
#. The operation is serialized with respect to operations on both |
| 1753 |
#. source and target futex. No other waiter can enqueue itself |
| 1754 |
#. for waiting and no other waiter can dequeue itself because of |
| 1755 |
#. a timeout or signal. |
| 1756 |
#. type: Plain text |
| 1757 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1758 |
msgid "" |
| 1759 |
"The load from I<uaddr> is an atomic memory access (i.e., using atomic " |
| 1760 |
"machine instructions of the respective architecture). This load, the " |
| 1761 |
"comparison with I<val3>, and the requeueing of any waiters are performed " |
| 1762 |
"atomically and totally ordered with respect to other operations on the same " |
| 1763 |
"futex word." |
| 1764 |
msgstr "" |
| 1765 |
|
| 1766 |
#. type: Plain text |
| 1767 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1768 |
msgid "" |
| 1769 |
"Typical values to specify for I<val> are 0 or 1. (Specifying B<INT_MAX> is " |
| 1770 |
"not useful, because it would make the B<FUTEX_CMP_REQUEUE> operation " |
| 1771 |
"equivalent to B<FUTEX_WAKE>.) The limit value specified via I<val2> is " |
| 1772 |
"typically either 1 or B<INT_MAX>. (Specifying the argument as 0 is not " |
| 1773 |
"useful, because it would make the B<FUTEX_CMP_REQUEUE> operation equivalent " |
| 1774 |
"to B<FUTEX_WAIT>.)" |
| 1775 |
msgstr "" |
| 1776 |
|
| 1777 |
#. But, as Rich Felker points out, there remain valid use cases for |
| 1778 |
#. FUTEX_REQUEUE, for example, when the calling thread is requeuing |
| 1779 |
#. the target(s) to a lock that the calling thread owns |
| 1780 |
#. From: Rich Felker <[email protected]> |
| 1781 |
#. Date: Wed, 29 Oct 2014 22:43:17 -0400 |
| 1782 |
#. To: Darren Hart <[email protected]> |
| 1783 |
#. CC: [email protected], ... |
| 1784 |
#. Subject: Re: Add futex wrapper to glibc? |
| 1785 |
#. type: Plain text |
| 1786 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1787 |
msgid "" |
| 1788 |
"The B<FUTEX_CMP_REQUEUE> operation was added as a replacement for the " |
| 1789 |
"earlier B<FUTEX_REQUEUE>. The difference is that the check of the value at " |
| 1790 |
"I<uaddr> can be used to ensure that requeueing happens only under certain " |
| 1791 |
"conditions, which allows race conditions to be avoided in certain use cases." |
| 1792 |
msgstr "" |
| 1793 |
|
| 1794 |
#. type: Plain text |
| 1795 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1796 |
msgid "" |
| 1797 |
"Both B<FUTEX_REQUEUE> and B<FUTEX_CMP_REQUEUE> can be used to avoid " |
| 1798 |
"\"thundering herd\" wake-ups that could occur when using B<FUTEX_WAKE> in " |
| 1799 |
"cases where all of the waiters that are woken need to acquire another " |
| 1800 |
"futex. Consider the following scenario, where multiple waiter threads are " |
| 1801 |
"waiting on B, a wait queue implemented using a futex:" |
| 1802 |
msgstr "" |
| 1803 |
|
| 1804 |
#. type: Plain text |
| 1805 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1806 |
#, no-wrap |
| 1807 |
msgid "" |
| 1808 |
"lock(A)\n" |
| 1809 |
"while (!check_value(V)) {\n" |
| 1810 |
" unlock(A);\n" |
| 1811 |
" block_on(B);\n" |
| 1812 |
" lock(A);\n" |
| 1813 |
"};\n" |
| 1814 |
"unlock(A);\n" |
| 1815 |
msgstr "" |
| 1816 |
|
| 1817 |
# |
| 1818 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1819 |
#. type: Plain text |
| 1820 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1821 |
msgid "" |
| 1822 |
"If a waker thread used B<FUTEX_WAKE>, then all waiters waiting on B would be " |
| 1823 |
"woken up, and they would all try to acquire lock A. However, waking all of " |
| 1824 |
"the threads in this manner would be pointless because all except one of the " |
| 1825 |
"threads would immediately block on lock A again. By contrast, a requeue " |
| 1826 |
"operation wakes just one waiter and moves the other waiters to lock A, and " |
| 1827 |
"when the woken waiter unlocks A then the next waiter can proceed." |
| 1828 |
msgstr "" |
| 1829 |
|
| 1830 |
#. type: TP |
| 1831 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1832 |
#, no-wrap |
| 1833 |
msgid "B<FUTEX_WAKE_OP> (since Linux 2.6.14)" |
| 1834 |
msgstr "" |
| 1835 |
|
| 1836 |
#. commit 4732efbeb997189d9f9b04708dc26bf8613ed721 |
| 1837 |
#. Author: Jakub Jelinek <[email protected]> |
| 1838 |
#. Date: Tue Sep 6 15:16:25 2005 -0700 |
| 1839 |
#. FIXME. (Torvald) The glibc condvar implementation is currently being |
| 1840 |
#. revised (e.g., to not use an internal lock anymore). |
| 1841 |
#. It is probably more future-proof to remove this paragraph. |
| 1842 |
#. [Torvald, do you have an update here?] |
| 1843 |
#. type: Plain text |
| 1844 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1845 |
msgid "" |
| 1846 |
"This operation was added to support some user-space use cases where more " |
| 1847 |
"than one futex must be handled at the same time. The most notable example " |
| 1848 |
"is the implementation of B<pthread_cond_signal>(3), which requires " |
| 1849 |
"operations on two futexes, the one used to implement the mutex and the one " |
| 1850 |
"used in the implementation of the wait queue associated with the condition " |
| 1851 |
"variable. B<FUTEX_WAKE_OP> allows such cases to be implemented without " |
| 1852 |
"leading to high rates of contention and context switching." |
| 1853 |
msgstr "" |
| 1854 |
|
| 1855 |
#. type: Plain text |
| 1856 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1857 |
msgid "" |
| 1858 |
"The B<FUTEX_WAKE_OP> operation is equivalent to executing the following code " |
| 1859 |
"atomically and totally ordered with respect to other futex operations on any " |
| 1860 |
"of the two supplied futex words:" |
| 1861 |
msgstr "" |
| 1862 |
|
| 1863 |
#. type: Plain text |
| 1864 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1865 |
#, no-wrap |
| 1866 |
msgid "" |
| 1867 |
"uint32_t oldval = *(uint32_t *) uaddr2;\n" |
| 1868 |
"*(uint32_t *) uaddr2 = oldval I<op> I<oparg>;\n" |
| 1869 |
"futex(uaddr, FUTEX_WAKE, val, 0, 0, 0);\n" |
| 1870 |
"if (oldval I<cmp> I<cmparg>)\n" |
| 1871 |
" futex(uaddr2, FUTEX_WAKE, val2, 0, 0, 0);\n" |
| 1872 |
msgstr "" |
| 1873 |
|
| 1874 |
#. type: Plain text |
| 1875 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1876 |
msgid "In other words, B<FUTEX_WAKE_OP> does the following:" |
| 1877 |
msgstr "" |
| 1878 |
|
| 1879 |
#. type: Plain text |
| 1880 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1881 |
msgid "" |
| 1882 |
"saves the original value of the futex word at I<uaddr2> and performs an " |
| 1883 |
"operation to modify the value of the futex at I<uaddr2>; this is an atomic " |
| 1884 |
"read-modify-write memory access (i.e., using atomic machine instructions of " |
| 1885 |
"the respective architecture)" |
| 1886 |
msgstr "" |
| 1887 |
|
| 1888 |
#. type: Plain text |
| 1889 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1890 |
msgid "" |
| 1891 |
"wakes up a maximum of I<val> waiters on the futex for the futex word at " |
| 1892 |
"I<uaddr>; and" |
| 1893 |
msgstr "" |
| 1894 |
|
| 1895 |
#. type: Plain text |
| 1896 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1897 |
msgid "" |
| 1898 |
"dependent on the results of a test of the original value of the futex word " |
| 1899 |
"at I<uaddr2>, wakes up a maximum of I<val2> waiters on the futex for the " |
| 1900 |
"futex word at I<uaddr2>." |
| 1901 |
msgstr "" |
| 1902 |
|
| 1903 |
#. type: Plain text |
| 1904 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1905 |
msgid "" |
| 1906 |
"The operation and comparison that are to be performed are encoded in the " |
| 1907 |
"bits of the argument I<val3>. Pictorially, the encoding is:" |
| 1908 |
msgstr "" |
| 1909 |
|
| 1910 |
#. type: Plain text |
| 1911 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1912 |
#, no-wrap |
| 1913 |
msgid "" |
| 1914 |
"+---+---+-----------+-----------+\n" |
| 1915 |
"|op |cmp| oparg | cmparg |\n" |
| 1916 |
"+---+---+-----------+-----------+\n" |
| 1917 |
" 4 4 12 12 E<lt>== # of bits\n" |
| 1918 |
msgstr "" |
| 1919 |
|
| 1920 |
#. type: Plain text |
| 1921 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1922 |
msgid "Expressed in code, the encoding is:" |
| 1923 |
msgstr "" |
| 1924 |
|
| 1925 |
#. type: Plain text |
| 1926 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1927 |
#, no-wrap |
| 1928 |
msgid "" |
| 1929 |
"#define FUTEX_OP(op, oparg, cmp, cmparg) \\[rs]\n" |
| 1930 |
" (((op & 0xf) E<lt>E<lt> 28) | \\[rs]\n" |
| 1931 |
" ((cmp & 0xf) E<lt>E<lt> 24) | \\[rs]\n" |
| 1932 |
" ((oparg & 0xfff) E<lt>E<lt> 12) | \\[rs]\n" |
| 1933 |
" (cmparg & 0xfff))\n" |
| 1934 |
msgstr "" |
| 1935 |
|
| 1936 |
#. type: Plain text |
| 1937 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1938 |
msgid "" |
| 1939 |
"In the above, I<op> and I<cmp> are each one of the codes listed below. The " |
| 1940 |
"I<oparg> and I<cmparg> components are literal numeric values, except as " |
| 1941 |
"noted below." |
| 1942 |
msgstr "" |
| 1943 |
|
| 1944 |
#. type: Plain text |
| 1945 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1946 |
msgid "The I<op> component has one of the following values:" |
| 1947 |
msgstr "" |
| 1948 |
|
| 1949 |
#. type: Plain text |
| 1950 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1951 |
#, no-wrap |
| 1952 |
msgid "" |
| 1953 |
"FUTEX_OP_SET 0 /* uaddr2 = oparg; */\n" |
| 1954 |
"FUTEX_OP_ADD 1 /* uaddr2 += oparg; */\n" |
| 1955 |
"FUTEX_OP_OR 2 /* uaddr2 |= oparg; */\n" |
| 1956 |
"FUTEX_OP_ANDN 3 /* uaddr2 &= \\[ti]oparg; */\n" |
| 1957 |
"FUTEX_OP_XOR 4 /* uaddr2 \\[ha]= oparg; */\n" |
| 1958 |
msgstr "" |
| 1959 |
|
| 1960 |
#. type: Plain text |
| 1961 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1962 |
msgid "" |
| 1963 |
"In addition, bitwise ORing the following value into I<op> causes I<(1\\ " |
| 1964 |
"E<lt>E<lt>\\ oparg)> to be used as the operand:" |
| 1965 |
msgstr "" |
| 1966 |
|
| 1967 |
#. type: Plain text |
| 1968 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1969 |
#, no-wrap |
| 1970 |
msgid "FUTEX_OP_ARG_SHIFT 8 /* Use (1 E<lt>E<lt> oparg) as operand */\n" |
| 1971 |
msgstr "" |
| 1972 |
|
| 1973 |
#. type: Plain text |
| 1974 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1975 |
msgid "The I<cmp> field is one of the following:" |
| 1976 |
msgstr "" |
| 1977 |
|
| 1978 |
#. type: Plain text |
| 1979 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1980 |
#, no-wrap |
| 1981 |
msgid "" |
| 1982 |
"FUTEX_OP_CMP_EQ 0 /* if (oldval == cmparg) wake */\n" |
| 1983 |
"FUTEX_OP_CMP_NE 1 /* if (oldval != cmparg) wake */\n" |
| 1984 |
"FUTEX_OP_CMP_LT 2 /* if (oldval E<lt> cmparg) wake */\n" |
| 1985 |
"FUTEX_OP_CMP_LE 3 /* if (oldval E<lt>= cmparg) wake */\n" |
| 1986 |
"FUTEX_OP_CMP_GT 4 /* if (oldval E<gt> cmparg) wake */\n" |
| 1987 |
"FUTEX_OP_CMP_GE 5 /* if (oldval E<gt>= cmparg) wake */\n" |
| 1988 |
msgstr "" |
| 1989 |
|
| 1990 |
# |
| 1991 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1992 |
#. type: Plain text |
| 1993 |
#: debian-trixie fedora-44 fedora-rawhide |
| 1994 |
msgid "" |
| 1995 |
"The return value of B<FUTEX_WAKE_OP> is the sum of the number of waiters " |
| 1996 |
"woken on the futex I<uaddr> plus the number of waiters woken on the futex " |
| 1997 |
"I<uaddr2>." |
| 1998 |
msgstr "" |
| 1999 |
|
| 2000 |
#. type: TP |
| 2001 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2002 |
#, no-wrap |
| 2003 |
msgid "B<FUTEX_WAIT_BITSET> (since Linux 2.6.25)" |
| 2004 |
msgstr "" |
| 2005 |
|
| 2006 |
#. commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d |
| 2007 |
#. type: Plain text |
| 2008 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2009 |
msgid "" |
| 2010 |
"This operation is like B<FUTEX_WAIT> except that I<val3> is used to provide " |
| 2011 |
"a 32-bit bit mask to the kernel. This bit mask, in which at least one bit " |
| 2012 |
"must be set, is stored in the kernel-internal state of the waiter. See the " |
| 2013 |
"description of B<FUTEX_WAKE_BITSET> for further details." |
| 2014 |
msgstr "" |
| 2015 |
|
| 2016 |
#. type: Plain text |
| 2017 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2018 |
msgid "" |
| 2019 |
"If I<timeout> is not NULL, the structure it points to specifies an absolute " |
| 2020 |
"timeout for the wait operation. If I<timeout> is NULL, the operation can " |
| 2021 |
"block indefinitely." |
| 2022 |
msgstr "" |
| 2023 |
|
| 2024 |
# |
| 2025 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2026 |
#. type: Plain text |
| 2027 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2028 |
msgid "The I<uaddr2> argument is ignored." |
| 2029 |
msgstr "" |
| 2030 |
|
| 2031 |
#. type: TP |
| 2032 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2033 |
#, no-wrap |
| 2034 |
msgid "B<FUTEX_WAKE_BITSET> (since Linux 2.6.25)" |
| 2035 |
msgstr "" |
| 2036 |
|
| 2037 |
#. commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d |
| 2038 |
#. type: Plain text |
| 2039 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2040 |
msgid "" |
| 2041 |
"This operation is the same as B<FUTEX_WAKE> except that the I<val3> argument " |
| 2042 |
"is used to provide a 32-bit bit mask to the kernel. This bit mask, in which " |
| 2043 |
"at least one bit must be set, is used to select which waiters should be " |
| 2044 |
"woken up. The selection is done by a bitwise AND of the \"wake\" bit mask " |
| 2045 |
"(i.e., the value in I<val3>) and the bit mask which is stored in the kernel-" |
| 2046 |
"internal state of the waiter (the \"wait\" bit mask that is set using " |
| 2047 |
"B<FUTEX_WAIT_BITSET>). All of the waiters for which the result of the AND " |
| 2048 |
"is nonzero are woken up; the remaining waiters are left sleeping." |
| 2049 |
msgstr "" |
| 2050 |
|
| 2051 |
# |
| 2052 |
# |
| 2053 |
#. According to http://locklessinc.com/articles/futex_cheat_sheet/: |
| 2054 |
#. "The original reason for the addition of these extensions |
| 2055 |
#. was to improve the performance of pthread read-write locks |
| 2056 |
#. in glibc. However, the pthreads library no longer uses the |
| 2057 |
#. same locking algorithm, and these extensions are not used |
| 2058 |
#. without the bitset parameter being all ones. |
| 2059 |
#. The page goes on to note that the FUTEX_WAIT_BITSET operation |
| 2060 |
#. is nevertheless used (with a bit mask of all ones) in order to |
| 2061 |
#. obtain the absolute timeout functionality that is useful |
| 2062 |
#. for efficiently implementing Pthreads APIs (which use absolute |
| 2063 |
#. timeouts); FUTEX_WAIT provides only relative timeouts. |
| 2064 |
#. type: Plain text |
| 2065 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2066 |
msgid "" |
| 2067 |
"The effect of B<FUTEX_WAIT_BITSET> and B<FUTEX_WAKE_BITSET> is to allow " |
| 2068 |
"selective wake-ups among multiple waiters that are blocked on the same " |
| 2069 |
"futex. However, note that, depending on the use case, employing this bit-" |
| 2070 |
"mask multiplexing feature on a futex can be less efficient than simply using " |
| 2071 |
"multiple futexes, because employing bit-mask multiplexing requires the " |
| 2072 |
"kernel to check all waiters on a futex, including those that are not " |
| 2073 |
"interested in being woken up (i.e., they do not have the relevant bit set in " |
| 2074 |
"their \"wait\" bit mask)." |
| 2075 |
msgstr "" |
| 2076 |
|
| 2077 |
#. type: Plain text |
| 2078 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2079 |
msgid "" |
| 2080 |
"The constant B<FUTEX_BITSET_MATCH_ANY>, which corresponds to all 32 bits set " |
| 2081 |
"in the bit mask, can be used as the I<val3> argument for " |
| 2082 |
"B<FUTEX_WAIT_BITSET> and B<FUTEX_WAKE_BITSET>. Other than differences in " |
| 2083 |
"the handling of the I<timeout> argument, the B<FUTEX_WAIT> operation is " |
| 2084 |
"equivalent to B<FUTEX_WAIT_BITSET> with I<val3> specified as " |
| 2085 |
"B<FUTEX_BITSET_MATCH_ANY>; that is, allow a wake-up by any waker. The " |
| 2086 |
"B<FUTEX_WAKE> operation is equivalent to B<FUTEX_WAKE_BITSET> with I<val3> " |
| 2087 |
"specified as B<FUTEX_BITSET_MATCH_ANY>; that is, wake up any waiter(s)." |
| 2088 |
msgstr "" |
| 2089 |
|
| 2090 |
# |
| 2091 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2092 |
#. type: Plain text |
| 2093 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2094 |
msgid "The I<uaddr2> and I<timeout> arguments are ignored." |
| 2095 |
msgstr "" |
| 2096 |
|
| 2097 |
#. type: Plain text |
| 2098 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2099 |
msgid "" |
| 2100 |
"If a futex is already acquired (i.e., has a nonzero value), waiters must " |
| 2101 |
"employ the B<FUTEX_LOCK_PI> or B<FUTEX_LOCK_PI2> operations to acquire the " |
| 2102 |
"lock. If other threads are waiting for the lock, then the B<FUTEX_WAITERS> " |
| 2103 |
"bit is set in the futex value; in this case, the lock owner must employ the " |
| 2104 |
"B<FUTEX_UNLOCK_PI> operation to release the lock." |
| 2105 |
msgstr "" |
| 2106 |
|
| 2107 |
#. type: Plain text |
| 2108 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2109 |
msgid "" |
| 2110 |
"PI futexes are operated on by specifying one of the values listed below in " |
| 2111 |
"I<futex_op>. Note that the PI futex operations must be used as paired " |
| 2112 |
"operations and are subject to some additional requirements:" |
| 2113 |
msgstr "" |
| 2114 |
|
| 2115 |
#. type: Plain text |
| 2116 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2117 |
msgid "" |
| 2118 |
"B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, and B<FUTEX_TRYLOCK_PI> pair with " |
| 2119 |
"B<FUTEX_UNLOCK_PI>. B<FUTEX_UNLOCK_PI> must be called only on a futex owned " |
| 2120 |
"by the calling thread, as defined by the value policy, otherwise the error " |
| 2121 |
"B<EPERM> results." |
| 2122 |
msgstr "" |
| 2123 |
|
| 2124 |
#. type: Plain text |
| 2125 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2126 |
msgid "" |
| 2127 |
"B<FUTEX_WAIT_REQUEUE_PI> pairs with B<FUTEX_CMP_REQUEUE_PI>. This must be " |
| 2128 |
"performed from a non-PI futex to a distinct PI futex (or the error B<EINVAL> " |
| 2129 |
"results). Additionally, I<val> (the number of waiters to be woken) must be " |
| 2130 |
"1 (or the error B<EINVAL> results)." |
| 2131 |
msgstr "" |
| 2132 |
|
| 2133 |
#. type: TP |
| 2134 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2135 |
#, no-wrap |
| 2136 |
msgid "B<FUTEX_LOCK_PI> (since Linux 2.6.18)" |
| 2137 |
msgstr "" |
| 2138 |
|
| 2139 |
#. commit c87e2837be82df479a6bae9f155c43516d2feebc |
| 2140 |
#. type: Plain text |
| 2141 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2142 |
msgid "" |
| 2143 |
"This operation is used after an attempt to acquire the lock via an atomic " |
| 2144 |
"user-mode instruction failed because the futex word has a nonzero value\\" |
| 2145 |
"[em]specifically, because it contained the (PID-namespace-specific) TID of " |
| 2146 |
"the lock owner." |
| 2147 |
msgstr "" |
| 2148 |
|
| 2149 |
# |
| 2150 |
# |
| 2151 |
# |
| 2152 |
# |
| 2153 |
#. tglx (July 2015): |
| 2154 |
#. The operation here is similar to the FUTEX_WAIT logic. When the user |
| 2155 |
#. space atomic acquire does not succeed because the futex value was non |
| 2156 |
#. zero, then the waiter goes into the kernel, takes the kernel internal |
| 2157 |
#. lock and retries the acquisition under the lock. If the acquisition |
| 2158 |
#. does not succeed either, then it sets the FUTEX_WAITERS bit, to signal |
| 2159 |
#. the lock owner that it needs to go into the kernel. Here is the pseudo |
| 2160 |
#. code: |
| 2161 |
#. lock(kernel_lock); |
| 2162 |
#. retry: |
| 2163 |
#. /* |
| 2164 |
#. * Owner might have unlocked in user space before we |
| 2165 |
#. * were able to set the waiter bit. |
| 2166 |
#. */ |
| 2167 |
#. if (atomic_acquire(futex) == SUCCESS) { |
| 2168 |
#. unlock(kernel_lock()); |
| 2169 |
#. return 0; |
| 2170 |
#. } |
| 2171 |
#. /* |
| 2172 |
#. * Owner might have unlocked after the above atomic_acquire() |
| 2173 |
#. * attempt. |
| 2174 |
#. */ |
| 2175 |
#. if (atomic_set_waiters_bit(futex) != SUCCESS) |
| 2176 |
#. goto retry; |
| 2177 |
#. queue_waiter(); |
| 2178 |
#. unlock(kernel_lock); |
| 2179 |
#. block(); |
| 2180 |
#. type: Plain text |
| 2181 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2182 |
msgid "" |
| 2183 |
"The operation checks the value of the futex word at the address I<uaddr>. " |
| 2184 |
"If the value is 0, then the kernel tries to atomically set the futex value " |
| 2185 |
"to the caller's TID. If the futex word's value is nonzero, the kernel " |
| 2186 |
"atomically sets the B<FUTEX_WAITERS> bit, which signals the futex owner that " |
| 2187 |
"it cannot unlock the futex in user space atomically by setting the futex " |
| 2188 |
"value to 0. After that, the kernel:" |
| 2189 |
msgstr "" |
| 2190 |
|
| 2191 |
#. type: IP |
| 2192 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2193 |
#, no-wrap |
| 2194 |
msgid "(1)" |
| 2195 |
msgstr "" |
| 2196 |
|
| 2197 |
#. type: Plain text |
| 2198 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2199 |
msgid "Tries to find the thread which is associated with the owner TID." |
| 2200 |
msgstr "" |
| 2201 |
|
| 2202 |
#. type: IP |
| 2203 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2204 |
#, no-wrap |
| 2205 |
msgid "(2)" |
| 2206 |
msgstr "" |
| 2207 |
|
| 2208 |
#. type: Plain text |
| 2209 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2210 |
msgid "" |
| 2211 |
"Creates or reuses kernel state on behalf of the owner. (If this is the " |
| 2212 |
"first waiter, there is no kernel state for this futex, so kernel state is " |
| 2213 |
"created by locking the RT-mutex and the futex owner is made the owner of the " |
| 2214 |
"RT-mutex. If there are existing waiters, then the existing state is reused.)" |
| 2215 |
msgstr "" |
| 2216 |
|
| 2217 |
#. type: IP |
| 2218 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2219 |
#, no-wrap |
| 2220 |
msgid "(3)" |
| 2221 |
msgstr "" |
| 2222 |
|
| 2223 |
#. type: Plain text |
| 2224 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2225 |
msgid "" |
| 2226 |
"Attaches the waiter to the futex (i.e., the waiter is enqueued on the RT-" |
| 2227 |
"mutex waiter list)." |
| 2228 |
msgstr "" |
| 2229 |
|
| 2230 |
# |
| 2231 |
#. August 2015: |
| 2232 |
#. mtk: If the realm is restricted purely to SCHED_OTHER (SCHED_NORMAL) |
| 2233 |
#. processes, does the nice value come into play also? |
| 2234 |
#. tglx: No. SCHED_OTHER/NORMAL tasks are handled in FIFO order |
| 2235 |
#. (i.e., task 1 blocks on lock A, held by task 2, |
| 2236 |
#. while task 2 blocks on lock B, held by task 3) |
| 2237 |
#. type: Plain text |
| 2238 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2239 |
msgid "" |
| 2240 |
"If more than one waiter exists, the enqueueing of the waiter is in " |
| 2241 |
"descending priority order. (For information on priority ordering, see the " |
| 2242 |
"discussion of the B<SCHED_DEADLINE>, B<SCHED_FIFO>, and B<SCHED_RR> " |
| 2243 |
"scheduling policies in B<sched>(7).) The owner inherits either the waiter's " |
| 2244 |
"CPU bandwidth (if the waiter is scheduled under the B<SCHED_DEADLINE> " |
| 2245 |
"policy) or the waiter's priority (if the waiter is scheduled under the " |
| 2246 |
"B<SCHED_RR> or B<SCHED_FIFO> policy). This inheritance follows the lock " |
| 2247 |
"chain in the case of nested locking and performs deadlock detection." |
| 2248 |
msgstr "" |
| 2249 |
|
| 2250 |
# |
| 2251 |
# |
| 2252 |
#. 2016-07-07 response from Thomas Gleixner on LKML: |
| 2253 |
#. From: Thomas Gleixner <[email protected]> |
| 2254 |
#. Date: 6 July 2016 at 20:57 |
| 2255 |
#. Subject: Re: futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op |
| 2256 |
#. On Thu, 23 Jun 2016, Michael Kerrisk (man-pages) wrote: |
| 2257 |
#. > On 06/23/2016 08:28 PM, Darren Hart wrote: |
| 2258 |
#. > > And as a follow-on, what is the reason for FUTEX_LOCK_PI only using |
| 2259 |
#. > > CLOCK_REALTIME? It seems reasonable to me that a user may want to wait a |
| 2260 |
#. > > specific amount of time, regardless of wall time. |
| 2261 |
#. > |
| 2262 |
#. > Yes, that's another weird inconsistency. |
| 2263 |
#. The reason is that phtread_mutex_timedlock() uses absolute timeouts based on |
| 2264 |
#. CLOCK_REALTIME. glibc folks asked to make that the default behaviour back |
| 2265 |
#. then when we added LOCK_PI. |
| 2266 |
#. type: Plain text |
| 2267 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2268 |
msgid "" |
| 2269 |
"The I<timeout> argument provides a timeout for the lock attempt. If " |
| 2270 |
"I<timeout> is not NULL, the structure it points to specifies an absolute " |
| 2271 |
"timeout, measured against the B<CLOCK_REALTIME> clock. If I<timeout> is " |
| 2272 |
"NULL, the operation will block indefinitely." |
| 2273 |
msgstr "" |
| 2274 |
|
| 2275 |
# |
| 2276 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2277 |
#. type: Plain text |
| 2278 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2279 |
msgid "The I<uaddr2>, I<val>, and I<val3> arguments are ignored." |
| 2280 |
msgstr "" |
| 2281 |
|
| 2282 |
#. type: TP |
| 2283 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2284 |
#, no-wrap |
| 2285 |
msgid "B<FUTEX_LOCK_PI2> (since Linux 5.14)" |
| 2286 |
msgstr "" |
| 2287 |
|
| 2288 |
# |
| 2289 |
#. commit bf22a6976897977b0a3f1aeba6823c959fc4fdae |
| 2290 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2291 |
#. type: Plain text |
| 2292 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2293 |
msgid "" |
| 2294 |
"This operation is the same as B<FUTEX_LOCK_PI>, except that the clock " |
| 2295 |
"against which I<timeout> is measured is selectable. By default, the " |
| 2296 |
"(absolute) timeout specified in I<timeout> is measured against the " |
| 2297 |
"B<CLOCK_MONOTONIC> clock, but if the B<FUTEX_CLOCK_REALTIME> flag is " |
| 2298 |
"specified in I<futex_op>, then the timeout is measured against the " |
| 2299 |
"B<CLOCK_REALTIME> clock." |
| 2300 |
msgstr "" |
| 2301 |
|
| 2302 |
#. type: TP |
| 2303 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2304 |
#, no-wrap |
| 2305 |
msgid "B<FUTEX_TRYLOCK_PI> (since Linux 2.6.18)" |
| 2306 |
msgstr "" |
| 2307 |
|
| 2308 |
#. commit c87e2837be82df479a6bae9f155c43516d2feebc |
| 2309 |
#. type: Plain text |
| 2310 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2311 |
msgid "" |
| 2312 |
"This operation tries to acquire the lock at I<uaddr>. It is invoked when a " |
| 2313 |
"user-space atomic acquire did not succeed because the futex word was not 0." |
| 2314 |
msgstr "" |
| 2315 |
|
| 2316 |
#. Paraphrasing a f2f conversation with Thomas Gleixner about the |
| 2317 |
#. above point (Aug 2015): ### |
| 2318 |
#. There is a rare possibility of a race condition involving an |
| 2319 |
#. uncontended futex with no owner, but with waiters. The |
| 2320 |
#. kernel-user-space contract is that if a futex is nonzero, you must |
| 2321 |
#. go into kernel. The futex was owned by a task, and that task dies |
| 2322 |
#. but there are no waiters, so the futex value is non zero. |
| 2323 |
#. Therefore, the next locker has to go into the kernel, |
| 2324 |
#. so that the kernel has a chance to clean up. (CMXCH on zero |
| 2325 |
#. in user space would fail, so kernel has to clean up.) |
| 2326 |
#. Darren Hart (Oct 2015): |
| 2327 |
#. The trylock in the kernel has more state, so it can independently |
| 2328 |
#. verify the flags that user space must trust implicitly. |
| 2329 |
#. type: Plain text |
| 2330 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2331 |
msgid "" |
| 2332 |
"Because the kernel has access to more state information than user space, " |
| 2333 |
"acquisition of the lock might succeed if performed by the kernel in cases " |
| 2334 |
"where the futex word (i.e., the state information accessible to use-space) " |
| 2335 |
"contains stale state (B<FUTEX_WAITERS> and/or B<FUTEX_OWNER_DIED>). This " |
| 2336 |
"can happen when the owner of the futex died. User space cannot handle this " |
| 2337 |
"condition in a race-free manner, but the kernel can fix this up and acquire " |
| 2338 |
"the futex." |
| 2339 |
msgstr "" |
| 2340 |
|
| 2341 |
# |
| 2342 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2343 |
#. type: Plain text |
| 2344 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2345 |
msgid "The I<uaddr2>, I<val>, I<timeout>, and I<val3> arguments are ignored." |
| 2346 |
msgstr "" |
| 2347 |
|
| 2348 |
#. type: TP |
| 2349 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2350 |
#, no-wrap |
| 2351 |
msgid "B<FUTEX_UNLOCK_PI> (since Linux 2.6.18)" |
| 2352 |
msgstr "" |
| 2353 |
|
| 2354 |
#. commit c87e2837be82df479a6bae9f155c43516d2feebc |
| 2355 |
#. type: Plain text |
| 2356 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2357 |
msgid "" |
| 2358 |
"This operation wakes the top priority waiter that is waiting in " |
| 2359 |
"B<FUTEX_LOCK_PI> or B<FUTEX_LOCK_PI2> on the futex address provided by the " |
| 2360 |
"I<uaddr> argument." |
| 2361 |
msgstr "" |
| 2362 |
|
| 2363 |
#. type: Plain text |
| 2364 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2365 |
msgid "" |
| 2366 |
"This is called when the user-space value at I<uaddr> cannot be changed " |
| 2367 |
"atomically from a TID (of the owner) to 0." |
| 2368 |
msgstr "" |
| 2369 |
|
| 2370 |
#. type: TP |
| 2371 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2372 |
#, no-wrap |
| 2373 |
msgid "B<FUTEX_CMP_REQUEUE_PI> (since Linux 2.6.31)" |
| 2374 |
msgstr "" |
| 2375 |
|
| 2376 |
#. commit 52400ba946759af28442dee6265c5c0180ac7122 |
| 2377 |
#. type: Plain text |
| 2378 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2379 |
msgid "" |
| 2380 |
"This operation is a PI-aware variant of B<FUTEX_CMP_REQUEUE>. It requeues " |
| 2381 |
"waiters that are blocked via B<FUTEX_WAIT_REQUEUE_PI> on I<uaddr> from a non-" |
| 2382 |
"PI source futex (I<uaddr>) to a PI target futex (I<uaddr2>)." |
| 2383 |
msgstr "" |
| 2384 |
|
| 2385 |
#. type: Plain text |
| 2386 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2387 |
msgid "" |
| 2388 |
"As with B<FUTEX_CMP_REQUEUE>, this operation wakes up a maximum of I<val> " |
| 2389 |
"waiters that are waiting on the futex at I<uaddr>. However, for " |
| 2390 |
"B<FUTEX_CMP_REQUEUE_PI>, I<val> is required to be 1 (since the main point is " |
| 2391 |
"to avoid a thundering herd). The remaining waiters are removed from the " |
| 2392 |
"wait queue of the source futex at I<uaddr> and added to the wait queue of " |
| 2393 |
"the target futex at I<uaddr2>." |
| 2394 |
msgstr "" |
| 2395 |
|
| 2396 |
# |
| 2397 |
# |
| 2398 |
#. val2 is the cap on the number of requeued waiters. |
| 2399 |
#. In the glibc pthread_cond_broadcast() implementation, this argument |
| 2400 |
#. is specified as INT_MAX, and for pthread_cond_signal() it is 0. |
| 2401 |
#. The page at http://locklessinc.com/articles/futex_cheat_sheet/ |
| 2402 |
#. notes that "priority-inheritance Futex to priority-inheritance |
| 2403 |
#. Futex requeues are currently unsupported". However, probably |
| 2404 |
#. the page does not need to say nothing about this, since |
| 2405 |
#. Thomas Gleixner commented (July 2015): "they never will be |
| 2406 |
#. supported because they make no sense at all" |
| 2407 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2408 |
#. type: Plain text |
| 2409 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2410 |
msgid "" |
| 2411 |
"The I<val2> and I<val3> arguments serve the same purposes as for " |
| 2412 |
"B<FUTEX_CMP_REQUEUE>." |
| 2413 |
msgstr "" |
| 2414 |
|
| 2415 |
#. type: TP |
| 2416 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2417 |
#, no-wrap |
| 2418 |
msgid "B<FUTEX_WAIT_REQUEUE_PI> (since Linux 2.6.31)" |
| 2419 |
msgstr "" |
| 2420 |
|
| 2421 |
#. commit 52400ba946759af28442dee6265c5c0180ac7122 |
| 2422 |
#. type: Plain text |
| 2423 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2424 |
msgid "" |
| 2425 |
"Wait on a non-PI futex at I<uaddr> and potentially be requeued (via a " |
| 2426 |
"B<FUTEX_CMP_REQUEUE_PI> operation in another task) onto a PI futex at " |
| 2427 |
"I<uaddr2>. The wait operation on I<uaddr> is the same as for B<FUTEX_WAIT>." |
| 2428 |
msgstr "" |
| 2429 |
|
| 2430 |
#. type: Plain text |
| 2431 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2432 |
msgid "" |
| 2433 |
"The waiter can be removed from the wait on I<uaddr> without requeueing on " |
| 2434 |
"I<uaddr2> via a B<FUTEX_WAKE> operation in another task. In this case, the " |
| 2435 |
"B<FUTEX_WAIT_REQUEUE_PI> operation fails with the error B<EAGAIN>." |
| 2436 |
msgstr "" |
| 2437 |
|
| 2438 |
#. type: Plain text |
| 2439 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2440 |
msgid "The I<val3> argument is ignored." |
| 2441 |
msgstr "" |
| 2442 |
|
| 2443 |
# |
| 2444 |
# |
| 2445 |
# |
| 2446 |
# |
| 2447 |
# |
| 2448 |
#. Darren Hart notes that a patch to allow glibc to fully support |
| 2449 |
#. PI-aware pthreads condition variables has not yet been accepted into |
| 2450 |
#. glibc. The story is complex, and can be found at |
| 2451 |
#. https://sourceware.org/bugzilla/show_bug.cgi?id=11588 |
| 2452 |
#. Darren notes that in the meantime, the patch is shipped with various |
| 2453 |
#. PREEMPT_RT-enabled Linux systems. |
| 2454 |
#. Related to the preceding, Darren proposed that somewhere, man-pages |
| 2455 |
#. should document the following point: |
| 2456 |
#. While the Linux kernel, since Linux 2.6.31, supports requeueing of |
| 2457 |
#. priority-inheritance (PI) aware mutexes via the |
| 2458 |
#. FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI futex operations, |
| 2459 |
#. the glibc implementation does not yet take full advantage of this. |
| 2460 |
#. Specifically, the condvar internal data lock remains a non-PI aware |
| 2461 |
#. mutex, regardless of the type of the pthread_mutex associated with |
| 2462 |
#. the condvar. This can lead to an unbounded priority inversion on |
| 2463 |
#. the internal data lock even when associating a PI aware |
| 2464 |
#. pthread_mutex with a condvar during a pthread_cond*_wait |
| 2465 |
#. operation. For this reason, it is not recommended to rely on |
| 2466 |
#. priority inheritance when using pthread condition variables. |
| 2467 |
#. The problem is that the obvious location for this text is |
| 2468 |
#. the pthread_cond*wait(3) man page. However, such a man page |
| 2469 |
#. does not currently exist. |
| 2470 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2471 |
#. type: Plain text |
| 2472 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2473 |
msgid "" |
| 2474 |
"The B<FUTEX_WAIT_REQUEUE_PI> and B<FUTEX_CMP_REQUEUE_PI> were added to " |
| 2475 |
"support a fairly specific use case: support for priority-inheritance-aware " |
| 2476 |
"POSIX threads condition variables. The idea is that these operations should " |
| 2477 |
"always be paired, in order to ensure that user space and the kernel remain " |
| 2478 |
"in sync. Thus, in the B<FUTEX_WAIT_REQUEUE_PI> operation, the user-space " |
| 2479 |
"application pre-specifies the target of the requeue that takes place in the " |
| 2480 |
"B<FUTEX_CMP_REQUEUE_PI> operation." |
| 2481 |
msgstr "" |
| 2482 |
|
| 2483 |
#. type: Plain text |
| 2484 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2485 |
msgid "" |
| 2486 |
"In the event of an error (and assuming that B<futex>() was invoked via " |
| 2487 |
"B<syscall>(2)), all operations return -1 and set I<errno> to indicate the " |
| 2488 |
"error." |
| 2489 |
msgstr "" |
| 2490 |
|
| 2491 |
#. type: Plain text |
| 2492 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2493 |
msgid "" |
| 2494 |
"The return value on success depends on the operation, as described in the " |
| 2495 |
"following list:" |
| 2496 |
msgstr "" |
| 2497 |
|
| 2498 |
#. type: TP |
| 2499 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2500 |
#, no-wrap |
| 2501 |
msgid "B<FUTEX_WAIT>" |
| 2502 |
msgstr "" |
| 2503 |
|
| 2504 |
#. type: Plain text |
| 2505 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2506 |
msgid "" |
| 2507 |
"Returns 0 if the caller was woken up. Note that a wake-up can also be " |
| 2508 |
"caused by common futex usage patterns in unrelated code that happened to " |
| 2509 |
"have previously used the futex word's memory location (e.g., typical futex-" |
| 2510 |
"based implementations of Pthreads mutexes can cause this under some " |
| 2511 |
"conditions). Therefore, callers should always conservatively assume that a " |
| 2512 |
"return value of 0 can mean a spurious wake-up, and use the futex word's " |
| 2513 |
"value (i.e., the user-space synchronization scheme) to decide whether to " |
| 2514 |
"continue to block or not." |
| 2515 |
msgstr "" |
| 2516 |
|
| 2517 |
#. type: TP |
| 2518 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2519 |
#, no-wrap |
| 2520 |
msgid "B<FUTEX_WAKE>" |
| 2521 |
msgstr "" |
| 2522 |
|
| 2523 |
#. type: Plain text |
| 2524 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2525 |
msgid "Returns the number of waiters that were woken up." |
| 2526 |
msgstr "" |
| 2527 |
|
| 2528 |
#. type: TP |
| 2529 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2530 |
#, no-wrap |
| 2531 |
msgid "B<FUTEX_FD>" |
| 2532 |
msgstr "" |
| 2533 |
|
| 2534 |
#. type: Plain text |
| 2535 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2536 |
msgid "Returns the new file descriptor associated with the futex." |
| 2537 |
msgstr "" |
| 2538 |
|
| 2539 |
#. type: TP |
| 2540 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2541 |
#, no-wrap |
| 2542 |
msgid "B<FUTEX_REQUEUE>" |
| 2543 |
msgstr "" |
| 2544 |
|
| 2545 |
#. type: TP |
| 2546 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2547 |
#, no-wrap |
| 2548 |
msgid "B<FUTEX_CMP_REQUEUE>" |
| 2549 |
msgstr "" |
| 2550 |
|
| 2551 |
#. type: Plain text |
| 2552 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2553 |
msgid "" |
| 2554 |
"Returns the total number of waiters that were woken up or requeued to the " |
| 2555 |
"futex for the futex word at I<uaddr2>. If this value is greater than " |
| 2556 |
"I<val>, then the difference is the number of waiters requeued to the futex " |
| 2557 |
"for the futex word at I<uaddr2>." |
| 2558 |
msgstr "" |
| 2559 |
|
| 2560 |
#. type: TP |
| 2561 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2562 |
#, no-wrap |
| 2563 |
msgid "B<FUTEX_WAKE_OP>" |
| 2564 |
msgstr "" |
| 2565 |
|
| 2566 |
#. type: Plain text |
| 2567 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2568 |
msgid "" |
| 2569 |
"Returns the total number of waiters that were woken up. This is the sum of " |
| 2570 |
"the woken waiters on the two futexes for the futex words at I<uaddr> and " |
| 2571 |
"I<uaddr2>." |
| 2572 |
msgstr "" |
| 2573 |
|
| 2574 |
#. type: TP |
| 2575 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2576 |
#, no-wrap |
| 2577 |
msgid "B<FUTEX_WAIT_BITSET>" |
| 2578 |
msgstr "" |
| 2579 |
|
| 2580 |
#. type: Plain text |
| 2581 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2582 |
msgid "" |
| 2583 |
"Returns 0 if the caller was woken up. See B<FUTEX_WAIT> for how to " |
| 2584 |
"interpret this correctly in practice." |
| 2585 |
msgstr "" |
| 2586 |
|
| 2587 |
#. type: TP |
| 2588 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2589 |
#, no-wrap |
| 2590 |
msgid "B<FUTEX_WAKE_BITSET>" |
| 2591 |
msgstr "" |
| 2592 |
|
| 2593 |
#. type: TP |
| 2594 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2595 |
#, no-wrap |
| 2596 |
msgid "B<FUTEX_LOCK_PI>" |
| 2597 |
msgstr "" |
| 2598 |
|
| 2599 |
#. type: Plain text |
| 2600 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2601 |
msgid "Returns 0 if the futex was successfully locked." |
| 2602 |
msgstr "" |
| 2603 |
|
| 2604 |
#. type: TP |
| 2605 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2606 |
#, no-wrap |
| 2607 |
msgid "B<FUTEX_LOCK_PI2>" |
| 2608 |
msgstr "" |
| 2609 |
|
| 2610 |
#. type: TP |
| 2611 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2612 |
#, no-wrap |
| 2613 |
msgid "B<FUTEX_TRYLOCK_PI>" |
| 2614 |
msgstr "" |
| 2615 |
|
| 2616 |
#. type: TP |
| 2617 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2618 |
#, no-wrap |
| 2619 |
msgid "B<FUTEX_UNLOCK_PI>" |
| 2620 |
msgstr "" |
| 2621 |
|
| 2622 |
#. type: Plain text |
| 2623 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2624 |
msgid "Returns 0 if the futex was successfully unlocked." |
| 2625 |
msgstr "" |
| 2626 |
|
| 2627 |
#. type: TP |
| 2628 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2629 |
#, no-wrap |
| 2630 |
msgid "B<FUTEX_CMP_REQUEUE_PI>" |
| 2631 |
msgstr "" |
| 2632 |
|
| 2633 |
#. type: Plain text |
| 2634 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2635 |
msgid "" |
| 2636 |
"Returns the total number of waiters that were woken up or requeued to the " |
| 2637 |
"futex for the futex word at I<uaddr2>. If this value is greater than " |
| 2638 |
"I<val>, then difference is the number of waiters requeued to the futex for " |
| 2639 |
"the futex word at I<uaddr2>." |
| 2640 |
msgstr "" |
| 2641 |
|
| 2642 |
#. type: TP |
| 2643 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2644 |
#, no-wrap |
| 2645 |
msgid "B<FUTEX_WAIT_REQUEUE_PI>" |
| 2646 |
msgstr "" |
| 2647 |
|
| 2648 |
# |
| 2649 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2650 |
#. type: Plain text |
| 2651 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2652 |
msgid "" |
| 2653 |
"Returns 0 if the caller was successfully requeued to the futex for the futex " |
| 2654 |
"word at I<uaddr2>." |
| 2655 |
msgstr "" |
| 2656 |
|
| 2657 |
#. type: TP |
| 2658 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2659 |
#, no-wrap |
| 2660 |
msgid "B<EAGAIN>" |
| 2661 |
msgstr "" |
| 2662 |
|
| 2663 |
#. type: Plain text |
| 2664 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2665 |
msgid "" |
| 2666 |
"(B<FUTEX_WAIT>, B<FUTEX_WAIT_BITSET>, B<FUTEX_WAIT_REQUEUE_PI>) The value " |
| 2667 |
"pointed to by I<uaddr> was not equal to the expected value I<val> at the " |
| 2668 |
"time of the call." |
| 2669 |
msgstr "" |
| 2670 |
|
| 2671 |
#. type: Plain text |
| 2672 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2673 |
msgid "" |
| 2674 |
"B<Note>: on Linux, the symbolic names B<EAGAIN> and B<EWOULDBLOCK> (both of " |
| 2675 |
"which appear in different parts of the kernel futex code) have the same " |
| 2676 |
"value." |
| 2677 |
msgstr "" |
| 2678 |
|
| 2679 |
#. type: Plain text |
| 2680 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2681 |
msgid "" |
| 2682 |
"(B<FUTEX_CMP_REQUEUE>, B<FUTEX_CMP_REQUEUE_PI>) The value pointed to by " |
| 2683 |
"I<uaddr> is not equal to the expected value I<val3>." |
| 2684 |
msgstr "" |
| 2685 |
|
| 2686 |
#. type: Plain text |
| 2687 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2688 |
msgid "" |
| 2689 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2690 |
"B<FUTEX_CMP_REQUEUE_PI>) The futex owner thread ID of I<uaddr> (for " |
| 2691 |
"B<FUTEX_CMP_REQUEUE_PI>: I<uaddr2>) is about to exit, but has not yet " |
| 2692 |
"handled the internal state cleanup. Try again." |
| 2693 |
msgstr "" |
| 2694 |
|
| 2695 |
#. type: TP |
| 2696 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2697 |
#, no-wrap |
| 2698 |
msgid "B<EDEADLK>" |
| 2699 |
msgstr "" |
| 2700 |
|
| 2701 |
#. type: Plain text |
| 2702 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2703 |
msgid "" |
| 2704 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2705 |
"B<FUTEX_CMP_REQUEUE_PI>) The futex word at I<uaddr> is already locked by " |
| 2706 |
"the caller." |
| 2707 |
msgstr "" |
| 2708 |
|
| 2709 |
# |
| 2710 |
#. FIXME . I see that kernel/locking/rtmutex.c uses EDEADLK in some |
| 2711 |
#. places, and EDEADLOCK in others. On almost all architectures |
| 2712 |
#. these constants are synonymous. Is there a reason that both |
| 2713 |
#. names are used? |
| 2714 |
#. tglx (July 2015): "No. We should probably fix that." |
| 2715 |
#. type: Plain text |
| 2716 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2717 |
msgid "" |
| 2718 |
"(B<FUTEX_CMP_REQUEUE_PI>) While requeueing a waiter to the PI futex for the " |
| 2719 |
"futex word at I<uaddr2>, the kernel detected a deadlock." |
| 2720 |
msgstr "" |
| 2721 |
|
| 2722 |
#. type: Plain text |
| 2723 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2724 |
msgid "" |
| 2725 |
"A required pointer argument (i.e., I<uaddr>, I<uaddr2>, or I<timeout>) did " |
| 2726 |
"not point to a valid user-space address." |
| 2727 |
msgstr "" |
| 2728 |
|
| 2729 |
#. type: TP |
| 2730 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2731 |
#, no-wrap |
| 2732 |
msgid "B<EINTR>" |
| 2733 |
msgstr "" |
| 2734 |
|
| 2735 |
#. type: Plain text |
| 2736 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2737 |
msgid "" |
| 2738 |
"A B<FUTEX_WAIT> or B<FUTEX_WAIT_BITSET> operation was interrupted by a " |
| 2739 |
"signal (see B<signal>(7)). Before Linux 2.6.22, this error could also be " |
| 2740 |
"returned for a spurious wakeup; since Linux 2.6.22, this no longer happens." |
| 2741 |
msgstr "" |
| 2742 |
|
| 2743 |
#. type: Plain text |
| 2744 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2745 |
msgid "" |
| 2746 |
"The operation in I<futex_op> is one of those that employs a timeout, but the " |
| 2747 |
"supplied I<timeout> argument was invalid (I<tv_sec> was less than zero, or " |
| 2748 |
"I<tv_nsec> was not less than 1,000,000,000)." |
| 2749 |
msgstr "" |
| 2750 |
|
| 2751 |
#. type: Plain text |
| 2752 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2753 |
msgid "" |
| 2754 |
"The operation specified in I<futex_op> employs one or both of the pointers " |
| 2755 |
"I<uaddr> and I<uaddr2>, but one of these does not point to a valid object\\" |
| 2756 |
"[em]that is, the address is not four-byte-aligned." |
| 2757 |
msgstr "" |
| 2758 |
|
| 2759 |
#. type: Plain text |
| 2760 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2761 |
msgid "" |
| 2762 |
"(B<FUTEX_WAIT_BITSET>, B<FUTEX_WAKE_BITSET>) The bit mask supplied in " |
| 2763 |
"I<val3> is zero." |
| 2764 |
msgstr "" |
| 2765 |
|
| 2766 |
#. type: Plain text |
| 2767 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2768 |
msgid "" |
| 2769 |
"(B<FUTEX_CMP_REQUEUE_PI>) I<uaddr> equals I<uaddr2> (i.e., an attempt was " |
| 2770 |
"made to requeue to the same futex)." |
| 2771 |
msgstr "" |
| 2772 |
|
| 2773 |
#. type: Plain text |
| 2774 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2775 |
msgid "(B<FUTEX_FD>) The signal number supplied in I<val> is invalid." |
| 2776 |
msgstr "" |
| 2777 |
|
| 2778 |
#. type: Plain text |
| 2779 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2780 |
msgid "" |
| 2781 |
"(B<FUTEX_WAKE>, B<FUTEX_WAKE_OP>, B<FUTEX_WAKE_BITSET>, B<FUTEX_REQUEUE>, " |
| 2782 |
"B<FUTEX_CMP_REQUEUE>) The kernel detected an inconsistency between the user-" |
| 2783 |
"space state at I<uaddr> and the kernel state\\[em]that is, it detected a " |
| 2784 |
"waiter which waits in B<FUTEX_LOCK_PI> or B<FUTEX_LOCK_PI2> on I<uaddr>." |
| 2785 |
msgstr "" |
| 2786 |
|
| 2787 |
#. type: Plain text |
| 2788 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2789 |
msgid "" |
| 2790 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2791 |
"B<FUTEX_UNLOCK_PI>) The kernel detected an inconsistency between the user-" |
| 2792 |
"space state at I<uaddr> and the kernel state. This indicates either state " |
| 2793 |
"corruption or that the kernel found a waiter on I<uaddr> which is waiting " |
| 2794 |
"via B<FUTEX_WAIT> or B<FUTEX_WAIT_BITSET>." |
| 2795 |
msgstr "" |
| 2796 |
|
| 2797 |
#. From a conversation with Thomas Gleixner (Aug 2015): ### |
| 2798 |
#. The kernel sees: I have non PI state for a futex you tried to |
| 2799 |
#. tell me was PI |
| 2800 |
#. type: Plain text |
| 2801 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2802 |
msgid "" |
| 2803 |
"(B<FUTEX_CMP_REQUEUE_PI>) The kernel detected an inconsistency between the " |
| 2804 |
"user-space state at I<uaddr2> and the kernel state; that is, the kernel " |
| 2805 |
"detected a waiter which waits via B<FUTEX_WAIT> or B<FUTEX_WAIT_BITSET> on " |
| 2806 |
"I<uaddr2>." |
| 2807 |
msgstr "" |
| 2808 |
|
| 2809 |
#. type: Plain text |
| 2810 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2811 |
msgid "" |
| 2812 |
"(B<FUTEX_CMP_REQUEUE_PI>) The kernel detected an inconsistency between the " |
| 2813 |
"user-space state at I<uaddr> and the kernel state; that is, the kernel " |
| 2814 |
"detected a waiter which waits via B<FUTEX_WAIT> or B<FUTEX_WAIT_BITSET> on " |
| 2815 |
"I<uaddr>." |
| 2816 |
msgstr "" |
| 2817 |
|
| 2818 |
#. type: Plain text |
| 2819 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2820 |
msgid "" |
| 2821 |
"(B<FUTEX_CMP_REQUEUE_PI>) The kernel detected an inconsistency between the " |
| 2822 |
"user-space state at I<uaddr> and the kernel state; that is, the kernel " |
| 2823 |
"detected a waiter which waits on I<uaddr> via B<FUTEX_LOCK_PI> or " |
| 2824 |
"B<FUTEX_LOCK_PI2> (instead of B<FUTEX_WAIT_REQUEUE_PI>)." |
| 2825 |
msgstr "" |
| 2826 |
|
| 2827 |
#. This deals with the case: |
| 2828 |
#. wait_requeue_pi(A, B); |
| 2829 |
#. requeue_pi(A, C); |
| 2830 |
#. type: Plain text |
| 2831 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2832 |
msgid "" |
| 2833 |
"(B<FUTEX_CMP_REQUEUE_PI>) An attempt was made to requeue a waiter to a " |
| 2834 |
"futex other than that specified by the matching B<FUTEX_WAIT_REQUEUE_PI> " |
| 2835 |
"call for that waiter." |
| 2836 |
msgstr "" |
| 2837 |
|
| 2838 |
#. type: Plain text |
| 2839 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2840 |
msgid "(B<FUTEX_CMP_REQUEUE_PI>) The I<val> argument is not 1." |
| 2841 |
msgstr "" |
| 2842 |
|
| 2843 |
#. type: TP |
| 2844 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2845 |
#, no-wrap |
| 2846 |
msgid "B<ENFILE>" |
| 2847 |
msgstr "" |
| 2848 |
|
| 2849 |
#. type: Plain text |
| 2850 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2851 |
msgid "" |
| 2852 |
"(B<FUTEX_FD>) The system-wide limit on the total number of open files has " |
| 2853 |
"been reached." |
| 2854 |
msgstr "" |
| 2855 |
|
| 2856 |
#. type: TP |
| 2857 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2858 |
#, no-wrap |
| 2859 |
msgid "B<ENOMEM>" |
| 2860 |
msgstr "" |
| 2861 |
|
| 2862 |
#. type: Plain text |
| 2863 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2864 |
msgid "" |
| 2865 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2866 |
"B<FUTEX_CMP_REQUEUE_PI>) The kernel could not allocate memory to hold state " |
| 2867 |
"information." |
| 2868 |
msgstr "" |
| 2869 |
|
| 2870 |
#. type: Plain text |
| 2871 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2872 |
msgid "Invalid operation specified in I<futex_op>." |
| 2873 |
msgstr "" |
| 2874 |
|
| 2875 |
#. type: Plain text |
| 2876 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2877 |
msgid "" |
| 2878 |
"The B<FUTEX_CLOCK_REALTIME> option was specified in I<futex_op>, but the " |
| 2879 |
"accompanying operation was neither B<FUTEX_WAIT>, B<FUTEX_WAIT_BITSET>, " |
| 2880 |
"B<FUTEX_WAIT_REQUEUE_PI>, nor B<FUTEX_LOCK_PI2>." |
| 2881 |
msgstr "" |
| 2882 |
|
| 2883 |
#. type: Plain text |
| 2884 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2885 |
msgid "" |
| 2886 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2887 |
"B<FUTEX_UNLOCK_PI>, B<FUTEX_CMP_REQUEUE_PI>, B<FUTEX_WAIT_REQUEUE_PI>) A " |
| 2888 |
"run-time check determined that the operation is not available. The PI-futex " |
| 2889 |
"operations are not implemented on all architectures and are not supported on " |
| 2890 |
"some CPU variants." |
| 2891 |
msgstr "" |
| 2892 |
|
| 2893 |
#. type: TP |
| 2894 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2895 |
#, no-wrap |
| 2896 |
msgid "B<EPERM>" |
| 2897 |
msgstr "" |
| 2898 |
|
| 2899 |
#. type: Plain text |
| 2900 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2901 |
msgid "" |
| 2902 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2903 |
"B<FUTEX_CMP_REQUEUE_PI>) The caller is not allowed to attach itself to the " |
| 2904 |
"futex at I<uaddr> (for B<FUTEX_CMP_REQUEUE_PI>: the futex at I<uaddr2>). " |
| 2905 |
"(This may be caused by a state corruption in user space.)" |
| 2906 |
msgstr "" |
| 2907 |
|
| 2908 |
#. type: Plain text |
| 2909 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2910 |
msgid "" |
| 2911 |
"(B<FUTEX_UNLOCK_PI>) The caller does not own the lock represented by the " |
| 2912 |
"futex word." |
| 2913 |
msgstr "" |
| 2914 |
|
| 2915 |
#. type: TP |
| 2916 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2917 |
#, no-wrap |
| 2918 |
msgid "B<ESRCH>" |
| 2919 |
msgstr "" |
| 2920 |
|
| 2921 |
#. type: Plain text |
| 2922 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2923 |
msgid "" |
| 2924 |
"(B<FUTEX_LOCK_PI>, B<FUTEX_LOCK_PI2>, B<FUTEX_TRYLOCK_PI>, " |
| 2925 |
"B<FUTEX_CMP_REQUEUE_PI>) The thread ID in the futex word at I<uaddr> does " |
| 2926 |
"not exist." |
| 2927 |
msgstr "" |
| 2928 |
|
| 2929 |
#. type: Plain text |
| 2930 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2931 |
msgid "" |
| 2932 |
"(B<FUTEX_CMP_REQUEUE_PI>) The thread ID in the futex word at I<uaddr2> does " |
| 2933 |
"not exist." |
| 2934 |
msgstr "" |
| 2935 |
|
| 2936 |
#. type: TP |
| 2937 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2938 |
#, no-wrap |
| 2939 |
msgid "B<ETIMEDOUT>" |
| 2940 |
msgstr "" |
| 2941 |
|
| 2942 |
# |
| 2943 |
#. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 2944 |
#. type: Plain text |
| 2945 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2946 |
msgid "" |
| 2947 |
"The operation in I<futex_op> employed the timeout specified in I<timeout>, " |
| 2948 |
"and the timeout expired before the operation completed." |
| 2949 |
msgstr "" |
| 2950 |
|
| 2951 |
#. type: Plain text |
| 2952 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2953 |
#, no-wrap |
| 2954 |
msgid "" |
| 2955 |
"$ B<./futex_demo>\n" |
| 2956 |
"Parent (18534) 0\n" |
| 2957 |
"Child (18535) 0\n" |
| 2958 |
"Parent (18534) 1\n" |
| 2959 |
"Child (18535) 1\n" |
| 2960 |
"Parent (18534) 2\n" |
| 2961 |
"Child (18535) 2\n" |
| 2962 |
"Parent (18534) 3\n" |
| 2963 |
"Child (18535) 3\n" |
| 2964 |
"Parent (18534) 4\n" |
| 2965 |
"Child (18535) 4\n" |
| 2966 |
msgstr "" |
| 2967 |
|
| 2968 |
#. type: Plain text |
| 2969 |
#: debian-trixie fedora-44 fedora-rawhide |
| 2970 |
#, no-wrap |
| 2971 |
msgid "" |
| 2972 |
"/* futex_demo.c\n" |
| 2973 |
"\\&\n" |
| 2974 |
" Usage: futex_demo [nloops]\n" |
| 2975 |
" (Default: 5)\n" |
| 2976 |
"\\&\n" |
| 2977 |
" Demonstrate the use of futexes in a program where parent and child\n" |
| 2978 |
" use a pair of futexes located inside a shared anonymous mapping to\n" |
| 2979 |
" synchronize access to a shared resource: the terminal. The two\n" |
| 2980 |
" processes each write \\[aq]num-loops\\[aq] messages to the terminal and employ\n" |
| 2981 |
" a synchronization protocol that ensures that they alternate in\n" |
| 2982 |
" writing messages.\n" |
| 2983 |
"*/\n" |
| 2984 |
"#define _GNU_SOURCE\n" |
| 2985 |
"#include E<lt>err.hE<gt>\n" |
| 2986 |
"#include E<lt>errno.hE<gt>\n" |
| 2987 |
"#include E<lt>linux/futex.hE<gt>\n" |
| 2988 |
"#include E<lt>stdatomic.hE<gt>\n" |
| 2989 |
"#include E<lt>stdint.hE<gt>\n" |
| 2990 |
"#include E<lt>stdio.hE<gt>\n" |
| 2991 |
"#include E<lt>stdlib.hE<gt>\n" |
| 2992 |
"#include E<lt>sys/mman.hE<gt>\n" |
| 2993 |
"#include E<lt>sys/syscall.hE<gt>\n" |
| 2994 |
"#include E<lt>sys/time.hE<gt>\n" |
| 2995 |
"#include E<lt>sys/wait.hE<gt>\n" |
| 2996 |
"#include E<lt>unistd.hE<gt>\n" |
| 2997 |
"\\&\n" |
| 2998 |
"static uint32_t *futex1, *futex2, *iaddr;\n" |
| 2999 |
"\\&\n" |
| 3000 |
"static int\n" |
| 3001 |
"futex(uint32_t *uaddr, int futex_op, uint32_t val,\n" |
| 3002 |
" const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3)\n" |
| 3003 |
"{\n" |
| 3004 |
" return syscall(SYS_futex, uaddr, futex_op, val,\n" |
| 3005 |
" timeout, uaddr2, val3);\n" |
| 3006 |
"}\n" |
| 3007 |
"\\&\n" |
| 3008 |
"/* Acquire the futex pointed to by \\[aq]futexp\\[aq]: wait for its value to\n" |
| 3009 |
" become 1, and then set the value to 0. */\n" |
| 3010 |
"\\&\n" |
| 3011 |
"static void\n" |
| 3012 |
"fwait(uint32_t *futexp)\n" |
| 3013 |
"{\n" |
| 3014 |
" long s;\n" |
| 3015 |
" const uint32_t one = 1;\n" |
| 3016 |
"\\&\n" |
| 3017 |
" /* atomic_compare_exchange_strong(ptr, oldval, newval)\n" |
| 3018 |
" atomically performs the equivalent of:\n" |
| 3019 |
"\\&\n" |
| 3020 |
" if (*ptr == *oldval)\n" |
| 3021 |
" *ptr = newval;\n" |
| 3022 |
"\\&\n" |
| 3023 |
" It returns true if the test yielded true and *ptr was updated. */\n" |
| 3024 |
"\\&\n" |
| 3025 |
" while (1) {\n" |
| 3026 |
"\\&\n" |
| 3027 |
" /* Is the futex available? */\n" |
| 3028 |
" if (atomic_compare_exchange_strong(futexp, &one, 0))\n" |
| 3029 |
" break; /* Yes */\n" |
| 3030 |
"\\&\n" |
| 3031 |
" /* Futex is not available; wait. */\n" |
| 3032 |
"\\&\n" |
| 3033 |
" s = futex(futexp, FUTEX_WAIT, 0, NULL, NULL, 0);\n" |
| 3034 |
" if (s == -1 && errno != EAGAIN)\n" |
| 3035 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAIT\");\n" |
| 3036 |
" }\n" |
| 3037 |
"}\n" |
| 3038 |
"\\&\n" |
| 3039 |
"/* Release the futex pointed to by \\[aq]futexp\\[aq]: if the futex currently\n" |
| 3040 |
" has the value 0, set its value to 1 and then wake any futex waiters,\n" |
| 3041 |
" so that if the peer is blocked in fwait(), it can proceed. */\n" |
| 3042 |
"\\&\n" |
| 3043 |
"static void\n" |
| 3044 |
"fpost(uint32_t *futexp)\n" |
| 3045 |
"{\n" |
| 3046 |
" long s;\n" |
| 3047 |
" const uint32_t zero = 0;\n" |
| 3048 |
"\\&\n" |
| 3049 |
" /* atomic_compare_exchange_strong() was described\n" |
| 3050 |
" in comments above. */\n" |
| 3051 |
"\\&\n" |
| 3052 |
" if (atomic_compare_exchange_strong(futexp, &zero, 1)) {\n" |
| 3053 |
" s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);\n" |
| 3054 |
" if (s == -1)\n" |
| 3055 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAKE\");\n" |
| 3056 |
" }\n" |
| 3057 |
"}\n" |
| 3058 |
"\\&\n" |
| 3059 |
"int\n" |
| 3060 |
"main(int argc, char *argv[])\n" |
| 3061 |
"{\n" |
| 3062 |
" pid_t childPid;\n" |
| 3063 |
" unsigned int nloops;\n" |
| 3064 |
"\\&\n" |
| 3065 |
" setbuf(stdout, NULL);\n" |
| 3066 |
"\\&\n" |
| 3067 |
" nloops = (argc E<gt> 1) ? atoi(argv[1]) : 5;\n" |
| 3068 |
"\\&\n" |
| 3069 |
" /* Create a shared anonymous mapping that will hold the futexes.\n" |
| 3070 |
" Since the futexes are being shared between processes, we\n" |
| 3071 |
" subsequently use the \"shared\" futex operations (i.e., not the\n" |
| 3072 |
" ones suffixed \"_PRIVATE\"). */\n" |
| 3073 |
"\\&\n" |
| 3074 |
" iaddr = mmap(NULL, sizeof(*iaddr) * 2, PROT_READ | PROT_WRITE,\n" |
| 3075 |
" MAP_ANONYMOUS | MAP_SHARED, -1, 0);\n" |
| 3076 |
" if (iaddr == MAP_FAILED)\n" |
| 3077 |
" err(EXIT_FAILURE, \"mmap\");\n" |
| 3078 |
"\\&\n" |
| 3079 |
" futex1 = &iaddr[0];\n" |
| 3080 |
" futex2 = &iaddr[1];\n" |
| 3081 |
"\\&\n" |
| 3082 |
" *futex1 = 0; /* State: unavailable */\n" |
| 3083 |
" *futex2 = 1; /* State: available */\n" |
| 3084 |
"\\&\n" |
| 3085 |
" /* Create a child process that inherits the shared anonymous\n" |
| 3086 |
" mapping. */\n" |
| 3087 |
"\\&\n" |
| 3088 |
" childPid = fork();\n" |
| 3089 |
" if (childPid == -1)\n" |
| 3090 |
" err(EXIT_FAILURE, \"fork\");\n" |
| 3091 |
"\\&\n" |
| 3092 |
" if (childPid == 0) { /* Child */\n" |
| 3093 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 3094 |
" fwait(futex1);\n" |
| 3095 |
" printf(\"Child (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 3096 |
" fpost(futex2);\n" |
| 3097 |
" }\n" |
| 3098 |
"\\&\n" |
| 3099 |
" exit(EXIT_SUCCESS);\n" |
| 3100 |
" }\n" |
| 3101 |
"\\&\n" |
| 3102 |
" /* Parent falls through to here. */\n" |
| 3103 |
"\\&\n" |
| 3104 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 3105 |
" fwait(futex2);\n" |
| 3106 |
" printf(\"Parent (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 3107 |
" fpost(futex1);\n" |
| 3108 |
" }\n" |
| 3109 |
"\\&\n" |
| 3110 |
" wait(NULL);\n" |
| 3111 |
"\\&\n" |
| 3112 |
" exit(EXIT_SUCCESS);\n" |
| 3113 |
"}\n" |
| 3114 |
msgstr "" |
| 3115 |
|
| 3116 |
#. type: Plain text |
| 3117 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3118 |
msgid "I<Documentation/pi-futex.txt>" |
| 3119 |
msgstr "" |
| 3120 |
|
| 3121 |
#. type: Plain text |
| 3122 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3123 |
msgid "I<Documentation/futex-requeue-pi.txt>" |
| 3124 |
msgstr "" |
| 3125 |
|
| 3126 |
#. type: Plain text |
| 3127 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3128 |
msgid "I<Documentation/locking/rt-mutex.txt>" |
| 3129 |
msgstr "" |
| 3130 |
|
| 3131 |
#. type: Plain text |
| 3132 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3133 |
msgid "I<Documentation/locking/rt-mutex-design.txt>" |
| 3134 |
msgstr "" |
| 3135 |
|
| 3136 |
#. type: Plain text |
| 3137 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3138 |
msgid "I<Documentation/robust-futex-ABI.txt>" |
| 3139 |
msgstr "" |
| 3140 |
|
| 3141 |
#. type: Plain text |
| 3142 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3143 |
msgid "" |
| 3144 |
"Franke, H., Russell, R., and Kirwood, M., 2002. I<Fuss, Futexes and " |
| 3145 |
"Furwocks: Fast Userlevel Locking in Linux> (from proceedings of the Ottawa " |
| 3146 |
"Linux Symposium 2002)," |
| 3147 |
msgstr "" |
| 3148 |
|
| 3149 |
#. type: Plain text |
| 3150 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3151 |
msgid "" |
| 3152 |
"E<.UR http://kernel.org\\:/doc\\:/ols\\:/2002\\:/ols2002-pages-479-495.pdf> " |
| 3153 |
"E<.UE>" |
| 3154 |
msgstr "" |
| 3155 |
|
| 3156 |
#. type: Plain text |
| 3157 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3158 |
msgid "" |
| 3159 |
"Hart, D., 2009. I<A futex overview and update>, E<.UR http://lwn.net/" |
| 3160 |
"Articles/360699/> E<.UE>" |
| 3161 |
msgstr "" |
| 3162 |
|
| 3163 |
#. type: Plain text |
| 3164 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3165 |
msgid "" |
| 3166 |
"Hart, D.\\& and Guniguntala, D., 2009. I<Requeue-PI: Making glibc Condvars " |
| 3167 |
"PI-Aware> (from proceedings of the 2009 Real-Time Linux Workshop), E<.UR " |
| 3168 |
"http://lwn.net/images/conf/rtlws11/papers/proc/p10.pdf> E<.UE>" |
| 3169 |
msgstr "" |
| 3170 |
|
| 3171 |
#. type: Plain text |
| 3172 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3173 |
msgid "" |
| 3174 |
"Drepper, U., 2011. I<Futexes Are Tricky>, E<.UR http://www.akkadia.org/" |
| 3175 |
"drepper/futex.pdf> E<.UE>" |
| 3176 |
msgstr "" |
| 3177 |
|
| 3178 |
#. type: Plain text |
| 3179 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3180 |
msgid "Futex example library, futex-*.tar.bz2 at" |
| 3181 |
msgstr "" |
| 3182 |
|
| 3183 |
#. type: Plain text |
| 3184 |
#: debian-trixie fedora-44 fedora-rawhide |
| 3185 |
msgid "" |
| 3186 |
"E<.UR https://mirrors.kernel.org\\:/pub\\:/linux\\:/kernel\\:/people\\:/" |
| 3187 |
"rusty/> E<.UE>" |
| 3188 |
msgstr "" |
| 3189 |
|
| 3190 |
#. type: TH |
| 3191 |
#: fedora-44 fedora-rawhide |
| 3192 |
#, no-wrap |
| 3193 |
msgid "2024-07-23" |
| 3194 |
msgstr "" |
| 3195 |
|
| 3196 |
#. type: TH |
| 3197 |
#: fedora-44 fedora-rawhide |
| 3198 |
#, no-wrap |
| 3199 |
msgid "Linux man-pages 6.13" |
| 3200 |
msgstr "" |
| 3201 |
|
| 3202 |
#. type: TH |
| 3203 |
#: mageia-cauldron |
| 3204 |
#, no-wrap |
| 3205 |
msgid "2026-02-08" |
| 3206 |
msgstr "" |
| 3207 |
|
| 3208 |
#. type: TH |
| 3209 |
#: mageia-cauldron |
| 3210 |
#, no-wrap |
| 3211 |
msgid "Linux man-pages 6.17" |
| 3212 |
msgstr "" |
| 3213 |
|
| 3214 |
#. type: Plain text |
| 3215 |
#: mageia-cauldron |
| 3216 |
#, no-wrap |
| 3217 |
msgid "" |
| 3218 |
"/* futex_demo.c\n" |
| 3219 |
"\\&\n" |
| 3220 |
" Usage: futex_demo [nloops]\n" |
| 3221 |
" (Default: 5)\n" |
| 3222 |
"\\&\n" |
| 3223 |
" Demonstrate the use of futexes in a program where parent and child\n" |
| 3224 |
" use a pair of futexes located inside a shared anonymous mapping to\n" |
| 3225 |
" synchronize access to a shared resource: the terminal. The two\n" |
| 3226 |
" processes each write \\[aq]num-loops\\[aq] messages to the terminal and employ\n" |
| 3227 |
" a synchronization protocol that ensures that they alternate in\n" |
| 3228 |
" writing messages.\n" |
| 3229 |
"*/\n" |
| 3230 |
"#define _GNU_SOURCE\n" |
| 3231 |
"#include E<lt>err.hE<gt>\n" |
| 3232 |
"#include E<lt>errno.hE<gt>\n" |
| 3233 |
"#include E<lt>linux/futex.hE<gt>\n" |
| 3234 |
"#include E<lt>stdatomic.hE<gt>\n" |
| 3235 |
"#include E<lt>stdint.hE<gt>\n" |
| 3236 |
"#include E<lt>stdio.hE<gt>\n" |
| 3237 |
"#include E<lt>stdlib.hE<gt>\n" |
| 3238 |
"#include E<lt>sys/mman.hE<gt>\n" |
| 3239 |
"#include E<lt>sys/syscall.hE<gt>\n" |
| 3240 |
"#include E<lt>sys/time.hE<gt>\n" |
| 3241 |
"#include E<lt>sys/wait.hE<gt>\n" |
| 3242 |
"#include E<lt>unistd.hE<gt>\n" |
| 3243 |
"\\&\n" |
| 3244 |
"static uint32_t *futex1, *futex2, *iaddr;\n" |
| 3245 |
"\\&\n" |
| 3246 |
"static int\n" |
| 3247 |
"futex(uint32_t *uaddr, int op, uint32_t val,\n" |
| 3248 |
" const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3)\n" |
| 3249 |
"{\n" |
| 3250 |
" return syscall(SYS_futex, uaddr, op, val,\n" |
| 3251 |
" timeout, uaddr2, val3);\n" |
| 3252 |
"}\n" |
| 3253 |
"\\&\n" |
| 3254 |
"/* Acquire the futex pointed to by \\[aq]futexp\\[aq]: wait for its value to\n" |
| 3255 |
" become 1, and then set the value to 0. */\n" |
| 3256 |
"\\&\n" |
| 3257 |
"static void\n" |
| 3258 |
"fwait(uint32_t *futexp)\n" |
| 3259 |
"{\n" |
| 3260 |
" long s;\n" |
| 3261 |
" const uint32_t one = 1;\n" |
| 3262 |
"\\&\n" |
| 3263 |
" /* atomic_compare_exchange_strong(ptr, oldval, newval)\n" |
| 3264 |
" atomically performs the equivalent of:\n" |
| 3265 |
"\\&\n" |
| 3266 |
" if (*ptr == *oldval)\n" |
| 3267 |
" *ptr = newval;\n" |
| 3268 |
"\\&\n" |
| 3269 |
" It returns true if the test yielded true and *ptr was updated. */\n" |
| 3270 |
"\\&\n" |
| 3271 |
" while (1) {\n" |
| 3272 |
"\\&\n" |
| 3273 |
" /* Is the futex available? */\n" |
| 3274 |
" if (atomic_compare_exchange_strong(futexp, &one, 0))\n" |
| 3275 |
" break; /* Yes */\n" |
| 3276 |
"\\&\n" |
| 3277 |
" /* Futex is not available; wait. */\n" |
| 3278 |
"\\&\n" |
| 3279 |
" s = futex(futexp, FUTEX_WAIT, 0, NULL, NULL, 0);\n" |
| 3280 |
" if (s == -1 && errno != EAGAIN)\n" |
| 3281 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAIT\");\n" |
| 3282 |
" }\n" |
| 3283 |
"}\n" |
| 3284 |
"\\&\n" |
| 3285 |
"/* Release the futex pointed to by \\[aq]futexp\\[aq]: if the futex currently\n" |
| 3286 |
" has the value 0, set its value to 1 and then wake any futex waiters,\n" |
| 3287 |
" so that if the peer is blocked in fwait(), it can proceed. */\n" |
| 3288 |
"\\&\n" |
| 3289 |
"static void\n" |
| 3290 |
"fpost(uint32_t *futexp)\n" |
| 3291 |
"{\n" |
| 3292 |
" long s;\n" |
| 3293 |
" const uint32_t zero = 0;\n" |
| 3294 |
"\\&\n" |
| 3295 |
" /* atomic_compare_exchange_strong() was described\n" |
| 3296 |
" in comments above. */\n" |
| 3297 |
"\\&\n" |
| 3298 |
" if (atomic_compare_exchange_strong(futexp, &zero, 1)) {\n" |
| 3299 |
" s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);\n" |
| 3300 |
" if (s == -1)\n" |
| 3301 |
" err(EXIT_FAILURE, \"futex-FUTEX_WAKE\");\n" |
| 3302 |
" }\n" |
| 3303 |
"}\n" |
| 3304 |
"\\&\n" |
| 3305 |
"int\n" |
| 3306 |
"main(int argc, char *argv[])\n" |
| 3307 |
"{\n" |
| 3308 |
" pid_t childPid;\n" |
| 3309 |
" unsigned int nloops;\n" |
| 3310 |
"\\&\n" |
| 3311 |
" setbuf(stdout, NULL);\n" |
| 3312 |
"\\&\n" |
| 3313 |
" nloops = (argc E<gt> 1) ? atoi(argv[1]) : 5;\n" |
| 3314 |
"\\&\n" |
| 3315 |
" /* Create a shared anonymous mapping that will hold the futexes.\n" |
| 3316 |
" Since the futexes are being shared between processes, we\n" |
| 3317 |
" subsequently use the \"shared\" futex operations (i.e., not the\n" |
| 3318 |
" ones suffixed \"_PRIVATE\"). */\n" |
| 3319 |
"\\&\n" |
| 3320 |
" iaddr = mmap(NULL, sizeof(*iaddr) * 2, PROT_READ | PROT_WRITE,\n" |
| 3321 |
" MAP_ANONYMOUS | MAP_SHARED, -1, 0);\n" |
| 3322 |
" if (iaddr == MAP_FAILED)\n" |
| 3323 |
" err(EXIT_FAILURE, \"mmap\");\n" |
| 3324 |
"\\&\n" |
| 3325 |
" futex1 = &iaddr[0];\n" |
| 3326 |
" futex2 = &iaddr[1];\n" |
| 3327 |
"\\&\n" |
| 3328 |
" *futex1 = 0; /* State: unavailable */\n" |
| 3329 |
" *futex2 = 1; /* State: available */\n" |
| 3330 |
"\\&\n" |
| 3331 |
" /* Create a child process that inherits the shared anonymous\n" |
| 3332 |
" mapping. */\n" |
| 3333 |
"\\&\n" |
| 3334 |
" childPid = fork();\n" |
| 3335 |
" if (childPid == -1)\n" |
| 3336 |
" err(EXIT_FAILURE, \"fork\");\n" |
| 3337 |
"\\&\n" |
| 3338 |
" if (childPid == 0) { /* Child */\n" |
| 3339 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 3340 |
" fwait(futex1);\n" |
| 3341 |
" printf(\"Child (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 3342 |
" fpost(futex2);\n" |
| 3343 |
" }\n" |
| 3344 |
"\\&\n" |
| 3345 |
" exit(EXIT_SUCCESS);\n" |
| 3346 |
" }\n" |
| 3347 |
"\\&\n" |
| 3348 |
" /* Parent falls through to here. */\n" |
| 3349 |
"\\&\n" |
| 3350 |
" for (unsigned int j = 0; j E<lt> nloops; j++) {\n" |
| 3351 |
" fwait(futex2);\n" |
| 3352 |
" printf(\"Parent (%jd) %u\\[rs]n\", (intmax_t) getpid(), j);\n" |
| 3353 |
" fpost(futex1);\n" |
| 3354 |
" }\n" |
| 3355 |
"\\&\n" |
| 3356 |
" wait(NULL);\n" |
| 3357 |
"\\&\n" |
| 3358 |
" exit(EXIT_SUCCESS);\n" |
| 3359 |
"}\n" |
| 3360 |
msgstr "" |
| 3361 |
|
| 3362 |
#. type: TH |
| 3363 |
#: opensuse-leap-16-1 opensuse-tumbleweed |
| 3364 |
#, no-wrap |
| 3365 |
msgid "Linux man-pages (unreleased)" |
| 3366 |
msgstr "" |