1GET_ROBUST_LIST(2) Linux System Calls GET_ROBUST_LIST(2)
2
3
4
6 get_robust_list, set_robust_list - get/set list of robust futexes
7
9 #include <linux/futex.h>
10 #include <sys/types.h>
11 #include <syscall.h>
12
13 long get_robust_list(int pid, struct robust_list_head **head_ptr,
14 size_t *len_ptr);
15 long set_robust_list(struct robust_list_head *head, size_t len);
16
17 Note: There are no glibc wrappers for these system calls; see NOTES.
18
20 These system calls deal with per-thread robust futex lists. These
21 lists are managed in user space: the kernel knows only about the loca‐
22 tion of the head of the list. A thread can inform the kernel of the
23 location of its robust futex list using set_robust_list(). The address
24 of a thread's robust futex list can be obtained using
25 get_robust_list().
26
27 The purpose of the robust futex list is to ensure that if a thread
28 accidentally fails to unlock a futex before terminating or calling
29 execve(2), another thread that is waiting on that futex is notified
30 that the former owner of the futex has died. This notification con‐
31 sists of two pieces: the FUTEX_OWNER_DIED bit is set in the futex word,
32 and the kernel performs a futex(2) FUTEX_WAKE operation on one of the
33 threads waiting on the futex.
34
35 The get_robust_list() system call returns the head of the robust futex
36 list of the thread whose thread ID is specified in pid. If pid is 0,
37 the head of the list for the calling thread is returned. The list head
38 is stored in the location pointed to by head_ptr. The size of the
39 object pointed to by **head_ptr is stored in len_ptr.
40
41 Permission to employ get_robust_list() is governed by a ptrace access
42 mode PTRACE_MODE_READ_REALCREDS check; see ptrace(2).
43
44 The set_robust_list() system call requests the kernel to record the
45 head of the list of robust futexes owned by the calling thread. The
46 head argument is the list head to record. The len argument should be
47 sizeof(*head).
48
50 The set_robust_list() and get_robust_list() system calls return zero
51 when the operation is successful, an error code otherwise.
52
54 The set_robust_list() system call can fail with the following error:
55
56 EINVAL len does not equal sizeof(struct robust_list_head).
57
58 The get_robust_list() system call can fail with the following errors:
59
60 EFAULT The head of the robust futex list can't be stored at the loca‐
61 tion head.
62
63 EPERM The calling process does not have permission to see the robust
64 futex list of the thread with the thread ID pid, and does not
65 have the CAP_SYS_PTRACE capability.
66
67 ESRCH No thread with the thread ID pid could be found.
68
70 These system calls were added in Linux 2.6.17.
71
73 These system calls are not needed by normal applications. No support
74 for them is provided in glibc. In the unlikely event that you want to
75 call them directly, use syscall(2).
76
77 A thread can have only one robust futex list; therefore applications
78 that wish to use this functionality should use the robust mutexes pro‐
79 vided by glibc.
80
81 In the initial implementation, a thread waiting on a futex was notified
82 that the owner had died only if the owner terminated. Starting with
83 Linux 2.6.28, notification was extended to include the case where the
84 owner performs an execve(2).
85
86 The thread IDs mentioned in the main text are kernel thread IDs of the
87 kind returned by clone(2) and gettid(2).
88
90 futex(2), pthread_mutexattr_setrobust(3)
91
92 Documentation/robust-futexes.txt and Documentation/robust-futex-ABI.txt
93 in the Linux kernel source tree
94
96 This page is part of release 5.07 of the Linux man-pages project. A
97 description of the project, information about reporting bugs, and the
98 latest version of this page, can be found at
99 https://www.kernel.org/doc/man-pages/.
100
101
102
103Linux 2019-10-10 GET_ROBUST_LIST(2)