Debian Codegraph @

po/es/man2/futex.2.po

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