1get_robust_list(2)            System Calls Manual           get_robust_list(2)
2
3
4

NAME

6       get_robust_list, set_robust_list - get/set list of robust futexes
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <linux/futex.h>   /* Definition of struct robust_list_head */
13       #include <sys/syscall.h>   /* Definition of SYS_* constants */
14       #include <unistd.h>
15
16       long syscall(SYS_get_robust_list, int pid,
17                    struct robust_list_head **head_ptr, size_t *len_ptr);
18       long syscall(SYS_set_robust_list,
19                    struct robust_list_head *head, size_t len);
20
21       Note:  glibc provides no wrappers for these system calls, necessitating
22       the use of syscall(2).
23

DESCRIPTION

25       These system calls deal with  per-thread  robust  futex  lists.   These
26       lists  are managed in user space: the kernel knows only about the loca‐
27       tion of the head of the list.  A thread can inform the  kernel  of  the
28       location of its robust futex list using set_robust_list().  The address
29       of  a  thread's  robust  futex  list  can  be  obtained  using  get_ro‐
30       bust_list().
31
32       The  purpose of the robust futex list is to ensure that if a thread ac‐
33       cidentally fails to unlock a futex before terminating  or  calling  ex‐
34       ecve(2),  another thread that is waiting on that futex is notified that
35       the former owner of the futex has died.  This notification consists  of
36       two  pieces: the FUTEX_OWNER_DIED bit is set in the futex word, and the
37       kernel performs a futex(2) FUTEX_WAKE operation on one of  the  threads
38       waiting on the futex.
39
40       The  get_robust_list() system call returns the head of the robust futex
41       list of the thread whose thread ID is specified in pid.  If pid  is  0,
42       the head of the list for the calling thread is returned.  The list head
43       is stored in the location pointed to by head_ptr.  The size of the  ob‐
44       ject pointed to by **head_ptr is stored in len_ptr.
45
46       Permission  to  employ get_robust_list() is governed by a ptrace access
47       mode PTRACE_MODE_READ_REALCREDS check; see ptrace(2).
48
49       The set_robust_list() system call requests the  kernel  to  record  the
50       head  of  the  list of robust futexes owned by the calling thread.  The
51       head argument is the list head to record.  The len argument  should  be
52       sizeof(*head).
53

RETURN VALUE

55       The  set_robust_list()  and  get_robust_list() system calls return zero
56       when the operation is successful, an error code otherwise.
57

ERRORS

59       The set_robust_list() system call can fail with the following error:
60
61       EINVAL len does not equal sizeof(struct robust_list_head).
62
63       The get_robust_list() system call can fail with the following errors:
64
65       EFAULT The head of the robust futex list can't be stored at  the  loca‐
66              tion head.
67
68       EPERM  The  calling  process does not have permission to see the robust
69              futex list of the thread with the thread ID pid,  and  does  not
70              have the CAP_SYS_PTRACE capability.
71
72       ESRCH  No thread with the thread ID pid could be found.
73

VERSIONS

75       These system calls were added in Linux 2.6.17.
76

NOTES

78       These system calls are not needed by normal applications.
79
80       A  thread  can  have only one robust futex list; therefore applications
81       that wish to use this functionality should use the robust mutexes  pro‐
82       vided by glibc.
83
84       In the initial implementation, a thread waiting on a futex was notified
85       that the owner had died only if the owner  terminated.   Starting  with
86       Linux  2.6.28,  notification was extended to include the case where the
87       owner performs an execve(2).
88
89       The thread IDs mentioned in the main text are kernel thread IDs of  the
90       kind returned by clone(2) and gettid(2).
91

SEE ALSO

93       futex(2), pthread_mutexattr_setrobust(3)
94
95       Documentation/robust-futexes.txt and Documentation/robust-futex-ABI.txt
96       in the Linux kernel source tree
97
98
99
100Linux man-pages 6.04              2022-10-30                get_robust_list(2)
Impressum