2013-03-10 09:28:35 +00:00
|
|
|
.\" Page by b.hubert
|
2015-01-13 08:26:39 +00:00
|
|
|
.\" and Copyright (C) 2015, Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
.\" and Copyright (C) 2015, Michael Kerrisk <mtk.manpages@gmail.com>
|
ldd.1, capget.2, clone.2, create_module.2, fallocate.2, futex.2, get_kernel_syms.2, get_thread_area.2, getcpu.2, getitimer.2, getpid.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl_list.2, mkdir.2, mknod.2, pciconfig_read.2, pivot_root.2, posix_fadvise.2, query_module.2, sendfile.2, set_thread_area.2, setns.2, unshare.2, __setfpucw.3, a64l.3, addseverity.3, argz_add.3, bindresvport.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, ccos.3, ccosh.3, cerf.3, cexp.3, cexp2.3, cimag.3, clog.3, clog10.3, clog2.3, cmsg.3, conj.3, cpow.3, cproj.3, creal.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, des_crypt.3, envz_add.3, fdim.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmtmsg.3, fpclassify.3, gamma.3, getpt.3, getrpcent.3, getrpcport.3, getttyent.3, isgreater.3, key_setsecret.3, lgamma.3, malloc_hook.3, mempcpy.3, nan.3, netlink.3, nextafter.3, putgrent.3, remove.3, remquo.3, rpc.3, rtime.3, rtnetlink.3, setaliasent.3, setnetgrent.3, signbit.3, significand.3, sincos.3, stdin.3, tgamma.3, xcrypt.3, xdr.3, cciss.4, hpsa.4, mouse.4, pts.4, sk98lin.4, tty_ioctl.4, wavelan.4, hosts.equiv.5, rpc.5, tzfile.5, boot.7, complex.7, ddp.7, fifo.7, futex.7, icmp.7, ip.7, ipv6.7, netdevice.7, netlink.7, packet.7, raw.7, rtnetlink.7, socket.7, tcp.7, udp.7, unix.7, x25.7, sync.8: Global fix: Put copyright info at top of page, followed by blank line and LICENSE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-10 09:29:51 +00:00
|
|
|
.\"
|
2013-03-10 09:29:11 +00:00
|
|
|
.\" %%%LICENSE_START(FREELY_REDISTRIBUTABLE)
|
2013-03-10 09:28:35 +00:00
|
|
|
.\" may be freely modified and distributed
|
epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, fallocate.2, futex.2, getcpu.2, getitimer.2, ioctl_list.2, ioprio_set.2, migrate_pages.2, move_pages.2, pciconfig_read.2, sendfile.2, setns.2, signalfd.2, spu_create.2, spu_run.2, sysinfo.2, timerfd_create.2, backtrace.3, cmsg.3, error.3, getpt.3, getrpcent.3, getrpcport.3, getsubopt.3, offsetof.3, program_invocation_name.3, rpc.3, rpmatch.3, rtnetlink.3, xdr.3, cciss.4, hpsa.4, pts.4, charmap.5, dir_colors.5, elf.5, gai.conf.5, locale.5, nscd.conf.5, nss.5, resolv.conf.5, rpc.5, arp.7, cpuset.7, ddp.7, epoll.7, fifo.7, futex.7, icmp.7, ip.7, ipv6.7, mailaddr.7, netdevice.7, packet.7, raw.7, regex.7, rtnetlink.7, socket.7, spufs.7, tcp.7, udp.7, unix.7, x25.7, ldconfig.8, nscd.8: Global fix: s/END_LICENSE/LICENSE_END/
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-12 09:26:07 +00:00
|
|
|
.\" %%%LICENSE_END
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" Niki A. Rahimi (LTC Security Development, narahimi@us.ibm.com)
|
|
|
|
.\" added ERRORS section.
|
|
|
|
.\"
|
|
|
|
.\" Modified 2004-06-17 mtk
|
|
|
|
.\" Modified 2004-10-07 aeb, added FUTEX_REQUEUE, FUTEX_CMP_REQUEUE
|
|
|
|
.\"
|
2015-01-27 07:22:02 +00:00
|
|
|
.\" FIXME Still to integrate are some points from Torvald Riegel's mail of
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" 2015-01-23:
|
2015-01-27 07:22:02 +00:00
|
|
|
.\" http://thread.gmane.org/gmane.linux.kernel/1703405/focus=7977
|
|
|
|
.\"
|
2015-04-15 20:29:56 +00:00
|
|
|
.\" FIXME Do we need to add some text regarding Torvald Riegel's 2015-01-24 mail
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" http://thread.gmane.org/gmane.linux.kernel/1703405/focus=1873242
|
2015-01-27 07:56:12 +00:00
|
|
|
.\"
|
ldd.1, localedef.1, add_key.2, chroot.2, clone.2, fork.2, futex.2, get_mempolicy.2, get_robust_list.2, getitimer.2, getpriority.2, ioctl.2, ioctl_ficlonerange.2, ioctl_fideduperange.2, kcmp.2, kill.2, lookup_dcookie.2, mmap.2, mount.2, open.2, pciconfig_read.2, perf_event_open.2, prctl.2, process_vm_readv.2, ptrace.2, quotactl.2, recv.2, setfsgid.2, setfsuid.2, sysinfo.2, umask.2, umount.2, unshare.2, utimensat.2, wait.2, assert.3, fmax.3, fmin.3, getauxval.3, inet_pton.3, malloc_hook.3, memmem.3, mkdtemp.3, mktemp.3, printf.3, strcasecmp.3, strcat.3, strtoul.3, strxfrm.3, console_codes.4, console_ioctl.4, lirc.4, tty.4, vcs.4, charmap.5, elf.5, locale.5, proc.5, repertoiremap.5, utmp.5, capabilities.7, cgroup_namespaces.7, cgroups.7, charsets.7, cp1251.7, cp1252.7, credentials.7, feature_test_macros.7, iso_8859-1.7, iso_8859-15.7, iso_8859-5.7, koi8-r.7, koi8-u.7, man-pages.7, mount_namespaces.7, namespaces.7, netlink.7, pid_namespaces.7, unix.7, user_namespaces.7, utf-8.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-07-17 16:07:58 +00:00
|
|
|
.TH FUTEX 2 2016-07-17 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
2012-10-21 06:19:01 +00:00
|
|
|
futex \- fast user-space locking
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH SYNOPSIS
|
2006-08-04 09:41:28 +00:00
|
|
|
.nf
|
2004-11-03 13:51:07 +00:00
|
|
|
.sp
|
|
|
|
.B "#include <linux/futex.h>"
|
|
|
|
.B "#include <sys/time.h>"
|
|
|
|
.sp
|
2015-01-12 14:40:43 +00:00
|
|
|
.BI "int futex(int *" uaddr ", int " futex_op ", int " val ,
|
2015-01-15 12:39:09 +00:00
|
|
|
.BI " const struct timespec *" timeout , \
|
2015-04-13 18:18:05 +00:00
|
|
|
" \fR /* or: \fBuint32_t \fIval2\fP */
|
2006-08-04 09:41:28 +00:00
|
|
|
.BI " int *" uaddr2 ", int " val3 );
|
|
|
|
.fi
|
2015-01-11 08:37:53 +00:00
|
|
|
|
2014-05-15 04:45:22 +00:00
|
|
|
.IR Note :
|
|
|
|
There is no glibc wrapper for this system call; see NOTES.
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH DESCRIPTION
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
The
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR futex ()
|
2015-03-02 16:33:18 +00:00
|
|
|
system call provides a method for waiting until a certain condition becomes
|
2015-03-03 06:22:31 +00:00
|
|
|
true.
|
|
|
|
It is typically used as a blocking construct in the context of
|
2015-07-28 07:51:35 +00:00
|
|
|
shared-memory synchronization.
|
|
|
|
When using futexes, the majority of
|
|
|
|
the synchronization operations are performed in user space.
|
2015-12-19 05:21:41 +00:00
|
|
|
A user-space program employs the
|
2015-07-28 07:51:35 +00:00
|
|
|
.BR futex ()
|
2015-08-09 08:38:40 +00:00
|
|
|
system call only when it is likely that the program has to block for
|
2015-03-28 08:47:43 +00:00
|
|
|
a longer time until the condition becomes true.
|
2015-12-19 05:21:41 +00:00
|
|
|
Other
|
2015-07-28 07:51:35 +00:00
|
|
|
.BR futex ()
|
2015-12-19 05:21:41 +00:00
|
|
|
operations can be used to wake any processes or threads waiting
|
|
|
|
for a particular condition.
|
2015-03-02 16:33:18 +00:00
|
|
|
|
2015-07-28 07:38:47 +00:00
|
|
|
A futex is a 32-bit value\(emreferred to below as a
|
|
|
|
.IR "futex word" \(emwhose
|
|
|
|
address is supplied to the
|
2015-03-02 16:33:18 +00:00
|
|
|
.BR futex ()
|
2015-07-28 07:38:47 +00:00
|
|
|
system call.
|
2015-12-15 12:11:15 +00:00
|
|
|
(Futexes are 32 bits in size on all platforms, including 64-bit systems.)
|
2015-07-28 07:38:47 +00:00
|
|
|
All futex operations are governed by this value.
|
|
|
|
In order to share a futex between processes,
|
|
|
|
the futex is placed in a region of shared memory,
|
|
|
|
created using (for example)
|
|
|
|
.BR mmap (2)
|
|
|
|
or
|
|
|
|
.BR shmat (2).
|
2015-12-15 12:11:15 +00:00
|
|
|
(Thus, the futex word may have different
|
2015-07-28 07:38:47 +00:00
|
|
|
virtual addresses in different processes,
|
|
|
|
but these addresses all refer to the same location in physical memory.)
|
2015-08-09 08:38:40 +00:00
|
|
|
In a multithreaded program, it is sufficient to place the futex word
|
|
|
|
in a global variable shared by all threads.
|
2015-01-18 09:45:23 +00:00
|
|
|
|
2015-04-11 07:07:15 +00:00
|
|
|
When executing a futex operation that requests to block a thread,
|
|
|
|
the kernel will block only if the futex word has the value that the
|
2015-07-28 08:51:45 +00:00
|
|
|
calling thread supplied (as one of the arguments of the
|
|
|
|
.BR futex ()
|
|
|
|
call) as the expected value of the futex word.
|
2015-07-28 08:04:10 +00:00
|
|
|
The loading of the futex word's value,
|
|
|
|
the comparison of that value with the expected value,
|
2015-12-19 05:21:41 +00:00
|
|
|
and the actual blocking will happen atomically and will be totally ordered
|
2015-12-16 15:53:45 +00:00
|
|
|
with respect to concurrent operations performed by other threads
|
2015-12-16 15:35:30 +00:00
|
|
|
on the same futex word.
|
2015-12-16 15:53:45 +00:00
|
|
|
.\" Notes from Darren Hart (Dec 2015):
|
|
|
|
.\" Totally ordered with respect futex operations refers to semantics
|
|
|
|
.\" of the ACQUIRE/RELEASE operations and how they impact ordering of
|
|
|
|
.\" memory reads and writes. The kernel futex operations are protected
|
2015-12-30 14:16:38 +00:00
|
|
|
.\" by spinlocks, which ensure that all operations are serialized
|
2015-12-16 15:53:45 +00:00
|
|
|
.\" with respect to one another.
|
|
|
|
.\"
|
|
|
|
.\" This is a lot to attempt to define in this document. Perhaps a
|
|
|
|
.\" reference to linux/Documentation/memory-barriers.txt as a footnote
|
|
|
|
.\" would be sufficient? Or perhaps for this manual, "serialized" would
|
|
|
|
.\" be sufficient, with a footnote regarding "totally ordered" and a
|
|
|
|
.\" pointer to the memory-barrier documentation?
|
2015-03-29 18:48:20 +00:00
|
|
|
Thus, the futex word is used to connect the synchronization in user space
|
2015-07-28 08:04:10 +00:00
|
|
|
with the implementation of blocking by the kernel.
|
2015-07-28 08:51:45 +00:00
|
|
|
Analogously to an atomic
|
2015-03-02 16:33:18 +00:00
|
|
|
compare-and-exchange operation that potentially changes shared memory,
|
2015-03-03 06:22:31 +00:00
|
|
|
blocking via a futex is an atomic compare-and-block operation.
|
2015-07-27 11:31:38 +00:00
|
|
|
.\" FIXME(Torvald Riegel):
|
2016-10-31 01:36:13 +00:00
|
|
|
.\" Eventually we want to have some text in NOTES to satisfy
|
|
|
|
.\" the reference in the following sentence
|
|
|
|
.\" See NOTES for a detailed specification of
|
|
|
|
.\" the synchronization semantics.
|
2015-03-02 16:33:18 +00:00
|
|
|
|
2015-08-09 08:38:40 +00:00
|
|
|
One use of futexes is for implementing locks.
|
2015-07-28 08:09:32 +00:00
|
|
|
The state of the lock (i.e., acquired or not acquired)
|
|
|
|
can be represented as an atomically accessed flag in shared memory.
|
2015-03-28 08:47:43 +00:00
|
|
|
In the uncontended case,
|
2015-12-15 12:11:15 +00:00
|
|
|
a thread can access or modify the lock state with atomic instructions,
|
2015-03-28 08:47:43 +00:00
|
|
|
for example atomically changing it from not acquired to acquired
|
|
|
|
using an atomic compare-and-exchange instruction.
|
2015-07-28 08:51:45 +00:00
|
|
|
(Such instructions are performed entirely in user mode,
|
|
|
|
and the kernel maintains no information about the lock state.)
|
|
|
|
On the other hand, a thread may be unable to acquire a lock because
|
2015-03-29 19:13:03 +00:00
|
|
|
it is already acquired by another thread.
|
2015-07-28 08:51:45 +00:00
|
|
|
It then may pass the lock's flag as a futex word and the value
|
2015-04-11 07:07:15 +00:00
|
|
|
representing the acquired state as the expected value to a
|
2015-03-29 19:13:03 +00:00
|
|
|
.BR futex ()
|
|
|
|
wait operation.
|
2015-07-28 08:51:45 +00:00
|
|
|
This
|
2015-03-29 19:13:03 +00:00
|
|
|
.BR futex ()
|
2015-12-19 05:21:41 +00:00
|
|
|
operation will block if and only if the lock is still acquired
|
2015-12-30 14:16:38 +00:00
|
|
|
(i.e., the value in the futex word still matches the "acquired state").
|
2015-03-03 06:22:31 +00:00
|
|
|
When releasing the lock, a thread has to first reset the
|
2015-04-11 07:07:15 +00:00
|
|
|
lock state to not acquired and then execute a futex
|
2015-07-28 08:51:45 +00:00
|
|
|
operation that wakes threads blocked on the lock flag used as a futex word
|
2015-12-30 14:16:38 +00:00
|
|
|
(this can be further optimized to avoid unnecessary wake-ups).
|
2015-03-03 06:22:31 +00:00
|
|
|
See
|
2015-03-02 16:33:18 +00:00
|
|
|
.BR futex (7)
|
|
|
|
for more detail on how to use futexes.
|
|
|
|
|
|
|
|
Besides the basic wait and wake-up futex functionality, there are further
|
2015-03-03 06:22:31 +00:00
|
|
|
futex operations aimed at supporting more complex use cases.
|
2015-08-09 08:38:40 +00:00
|
|
|
|
|
|
|
Note that
|
2015-12-19 05:22:47 +00:00
|
|
|
no explicit initialization or destruction is necessary to use futexes;
|
2015-03-28 08:47:43 +00:00
|
|
|
the kernel maintains a futex
|
|
|
|
(i.e., the kernel-internal implementation artifact)
|
2015-03-02 16:33:18 +00:00
|
|
|
only while operations such as
|
|
|
|
.BR FUTEX_WAIT ,
|
|
|
|
described below, are being performed on a particular futex word.
|
2015-01-18 07:58:32 +00:00
|
|
|
.\"
|
|
|
|
.SS Arguments
|
2004-11-03 13:51:07 +00:00
|
|
|
The
|
|
|
|
.I uaddr
|
2015-03-03 06:22:31 +00:00
|
|
|
argument points to the futex word.
|
|
|
|
On all platforms, futexes are four-byte
|
2015-03-02 16:33:18 +00:00
|
|
|
integers that must be aligned on a four-byte boundary.
|
2015-01-13 07:48:54 +00:00
|
|
|
The operation to perform on the futex is specified in the
|
|
|
|
.I futex_op
|
|
|
|
argument;
|
|
|
|
.IR val
|
|
|
|
is a value whose meaning and purpose depends on
|
|
|
|
.IR futex_op .
|
2015-01-13 08:00:29 +00:00
|
|
|
|
|
|
|
The remaining arguments
|
|
|
|
.RI ( timeout ,
|
|
|
|
.IR uaddr2 ,
|
|
|
|
and
|
|
|
|
.IR val3 )
|
|
|
|
are required only for certain of the futex operations described below.
|
|
|
|
Where one of these arguments is not required, it is ignored.
|
2015-01-15 12:39:09 +00:00
|
|
|
|
2015-01-13 08:00:29 +00:00
|
|
|
For several blocking operations, the
|
|
|
|
.I timeout
|
|
|
|
argument is a pointer to a
|
|
|
|
.IR timespec
|
|
|
|
structure that specifies a timeout for the operation.
|
|
|
|
However, notwithstanding the prototype shown above, for some operations,
|
2015-04-13 18:50:18 +00:00
|
|
|
the least significant four bytes are used as an integer whose meaning
|
2015-01-13 08:00:29 +00:00
|
|
|
is determined by the operation.
|
2015-01-15 12:39:09 +00:00
|
|
|
For these operations, the kernel casts the
|
|
|
|
.I timeout
|
2015-04-13 18:50:18 +00:00
|
|
|
value first to
|
|
|
|
.IR "unsigned long",
|
|
|
|
then to
|
2015-04-13 18:18:05 +00:00
|
|
|
.IR uint32_t ,
|
2015-01-15 12:39:09 +00:00
|
|
|
and in the remainder of this page, this argument is referred to as
|
|
|
|
.I val2
|
|
|
|
when interpreted in this fashion.
|
|
|
|
|
2015-01-15 12:43:19 +00:00
|
|
|
Where it is required, the
|
2015-01-13 08:00:29 +00:00
|
|
|
.IR uaddr2
|
2015-03-28 08:47:43 +00:00
|
|
|
argument is a pointer to a second futex word that is employed
|
|
|
|
by the operation.
|
2016-06-24 07:28:56 +00:00
|
|
|
|
2015-01-13 08:00:29 +00:00
|
|
|
The interpretation of the final integer argument,
|
|
|
|
.IR val3 ,
|
|
|
|
depends on the operation.
|
2015-01-18 07:58:32 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
|
|
|
.SS Futex operations
|
2015-01-12 07:22:31 +00:00
|
|
|
The
|
2015-01-12 14:40:43 +00:00
|
|
|
.I futex_op
|
2015-01-12 07:22:31 +00:00
|
|
|
argument consists of two parts:
|
|
|
|
a command that specifies the operation to be performed,
|
2016-02-02 20:50:47 +00:00
|
|
|
bit-wise ORed with zero or more options that
|
2015-01-12 07:22:31 +00:00
|
|
|
modify the behaviour of the operation.
|
2015-01-12 07:23:53 +00:00
|
|
|
The options that may be included in
|
2015-01-12 14:40:43 +00:00
|
|
|
.I futex_op
|
2015-01-12 07:23:53 +00:00
|
|
|
are as follows:
|
|
|
|
.TP
|
|
|
|
.BR FUTEX_PRIVATE_FLAG " (since Linux 2.6.22)"
|
|
|
|
.\" commit 34f01cc1f512fa783302982776895c73714ebbc2
|
|
|
|
This option bit can be employed with all futex operations.
|
2015-01-15 19:35:16 +00:00
|
|
|
It tells the kernel that the futex is process-private and not shared
|
2015-04-11 07:07:15 +00:00
|
|
|
with another process (i.e., it is being used for synchronization
|
|
|
|
only between threads of the same process).
|
2015-07-27 10:49:56 +00:00
|
|
|
This allows the kernel to make some additional performance optimizations.
|
|
|
|
.\" I.e., It allows the kernel choose the fast path for validating
|
|
|
|
.\" the user-space address and avoids expensive VMA lookups,
|
|
|
|
.\" taking reference counts on file backing store, and so on.
|
2015-01-13 11:25:17 +00:00
|
|
|
|
|
|
|
As a convenience,
|
|
|
|
.IR <linux/futex.h>
|
|
|
|
defines a set of constants with the suffix
|
|
|
|
.BR _PRIVATE
|
|
|
|
that are equivalents of all of the operations listed below,
|
2015-01-14 05:49:44 +00:00
|
|
|
.\" except the obsolete FUTEX_FD, for which the "private" flag was
|
2015-01-13 11:25:17 +00:00
|
|
|
.\" meaningless
|
|
|
|
but with the
|
|
|
|
.BR FUTEX_PRIVATE_FLAG
|
|
|
|
ORed into the constant value.
|
|
|
|
Thus, there are
|
|
|
|
.BR FUTEX_WAIT_PRIVATE ,
|
|
|
|
.BR FUTEX_WAKE_PRIVATE ,
|
|
|
|
and so on.
|
2015-01-12 07:34:58 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_CLOCK_REALTIME " (since Linux 2.6.28)"
|
|
|
|
.\" commit 1acdac104668a0834cfa267de9946fac7764d486
|
2015-01-12 11:52:28 +00:00
|
|
|
This option bit can be employed only with the
|
2016-03-14 23:57:01 +00:00
|
|
|
.BR FUTEX_WAIT_BITSET ,
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI ,
|
2015-01-12 07:34:58 +00:00
|
|
|
and
|
2016-03-14 23:57:01 +00:00
|
|
|
(since Linux 4.5)
|
|
|
|
.\" commit 337f13046ff03717a9e99675284a817527440a49
|
2016-06-24 06:49:18 +00:00
|
|
|
.BR FUTEX_WAIT
|
2015-01-15 05:18:01 +00:00
|
|
|
operations.
|
2015-01-12 07:34:58 +00:00
|
|
|
|
2016-06-23 10:43:51 +00:00
|
|
|
If this option is set, the kernel measures the
|
2015-01-14 05:49:31 +00:00
|
|
|
.I timeout
|
2016-06-23 10:43:51 +00:00
|
|
|
against the
|
|
|
|
.BR CLOCK_REALTIME
|
|
|
|
clock.
|
2015-01-12 07:34:58 +00:00
|
|
|
|
2016-06-23 10:43:51 +00:00
|
|
|
If this option is not set, the kernel measures the
|
2015-01-14 05:49:31 +00:00
|
|
|
.I timeout
|
2016-06-23 10:43:51 +00:00
|
|
|
against the
|
2015-01-12 12:47:01 +00:00
|
|
|
.BR CLOCK_MONOTONIC
|
|
|
|
clock.
|
2015-01-12 07:22:31 +00:00
|
|
|
.PP
|
|
|
|
The operation specified in
|
2015-01-12 14:40:43 +00:00
|
|
|
.I futex_op
|
2015-01-12 07:22:31 +00:00
|
|
|
is one of the following:
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2015-01-12 12:24:43 +00:00
|
|
|
.BR FUTEX_WAIT " (since Linux 2.6.0)"
|
|
|
|
.\" Strictly speaking, since some time in 2.5.x
|
2015-01-12 13:01:22 +00:00
|
|
|
This operation tests that the value at the
|
2015-03-02 16:33:18 +00:00
|
|
|
futex word pointed to by the address
|
2004-11-03 13:51:07 +00:00
|
|
|
.I uaddr
|
2015-03-02 16:33:18 +00:00
|
|
|
still contains the expected value
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR val ,
|
2015-07-28 09:09:15 +00:00
|
|
|
and if so, then sleeps waiting for a
|
2007-06-22 17:16:20 +00:00
|
|
|
.B FUTEX_WAKE
|
2015-07-28 09:09:15 +00:00
|
|
|
operation on the futex word.
|
2015-03-03 06:22:31 +00:00
|
|
|
The load of the value of the futex word is an atomic memory
|
2015-03-02 16:33:18 +00:00
|
|
|
access (i.e., using atomic machine instructions of the respective
|
2015-03-03 06:22:31 +00:00
|
|
|
architecture).
|
|
|
|
This load, the comparison with the expected value, and
|
2015-07-28 09:09:15 +00:00
|
|
|
starting to sleep are performed atomically
|
2015-07-29 11:20:52 +00:00
|
|
|
.\" FIXME: Torvald, I think we may need to add some explanation of
|
2016-10-31 01:36:13 +00:00
|
|
|
.\" "totally ordered" here.
|
2015-07-28 09:09:15 +00:00
|
|
|
and totally ordered
|
|
|
|
with respect to other futex operations on the same futex word.
|
2015-07-28 08:09:32 +00:00
|
|
|
If the thread starts to sleep,
|
|
|
|
it is considered a waiter on this futex word.
|
2015-01-12 13:01:22 +00:00
|
|
|
If the futex value does not match
|
|
|
|
.IR val ,
|
2015-01-13 08:11:03 +00:00
|
|
|
then the call fails immediately with the error
|
2015-01-14 16:16:58 +00:00
|
|
|
.BR EAGAIN .
|
2015-03-02 16:33:18 +00:00
|
|
|
|
|
|
|
The purpose of the comparison with the expected value is to prevent lost
|
2015-07-28 09:09:15 +00:00
|
|
|
wake-ups.
|
|
|
|
If another thread changed the value of the futex word after the
|
2015-07-28 08:09:32 +00:00
|
|
|
calling thread decided to block based on the prior value,
|
|
|
|
and if the other thread executed a
|
2015-03-02 16:33:18 +00:00
|
|
|
.BR FUTEX_WAKE
|
|
|
|
operation (or similar wake-up) after the value change and before this
|
2015-01-12 13:01:22 +00:00
|
|
|
.BR FUTEX_WAIT
|
2015-12-19 05:21:41 +00:00
|
|
|
operation, then the calling thread will observe the
|
|
|
|
value change and will not start to sleep.
|
2015-01-12 12:41:46 +00:00
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
If the
|
2004-11-03 13:51:07 +00:00
|
|
|
.I timeout
|
2016-06-24 06:52:16 +00:00
|
|
|
is not NULL, the structure it points to specifies a
|
|
|
|
timeout for the wait.
|
2016-06-24 06:54:38 +00:00
|
|
|
(This interval will be rounded up to the system clock granularity,
|
|
|
|
and is guaranteed not to expire early.)
|
2016-06-24 06:54:03 +00:00
|
|
|
The timeout is by default measured according to the
|
2015-01-12 12:47:01 +00:00
|
|
|
.BR CLOCK_MONOTONIC
|
2016-06-24 06:39:40 +00:00
|
|
|
clock, but, since Linux 4.5, the
|
|
|
|
.BR CLOCK_REALTIME
|
|
|
|
clock can be selected by specifying
|
|
|
|
.BR FUTEX_CLOCK_REALTIME
|
|
|
|
in
|
|
|
|
.IR futex_op .
|
2013-09-04 08:24:01 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is NULL, the call blocks indefinitely.
|
2014-06-04 07:48:23 +00:00
|
|
|
|
2016-06-24 08:20:40 +00:00
|
|
|
.IR Note :
|
|
|
|
for
|
|
|
|
.BR FUTEX_WAIT ,
|
|
|
|
.IR timeout
|
|
|
|
is interpreted as a
|
|
|
|
.IR relative
|
|
|
|
value.
|
|
|
|
This differs from other futex operations, where
|
|
|
|
.I timeout
|
|
|
|
is interpreted as an absolute value.
|
|
|
|
To obtain the equivalent of
|
|
|
|
.BR FUTEX_WAIT
|
|
|
|
with an absolute timeout, employ
|
|
|
|
.BR FUTEX_WAIT_BITSET
|
|
|
|
with
|
|
|
|
.IR val3
|
|
|
|
specified as
|
|
|
|
.BR FUTEX_BITSET_MATCH_ANY .
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
The arguments
|
2004-11-03 13:51:07 +00:00
|
|
|
.I uaddr2
|
|
|
|
and
|
|
|
|
.I val3
|
|
|
|
are ignored.
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" FIXME . (Torvald) I think we should remove this. Or maybe adapt to a
|
|
|
|
.\" different example.
|
|
|
|
.\"
|
|
|
|
.\" For
|
|
|
|
.\" .BR futex (7),
|
|
|
|
.\" this call is executed if decrementing the count gave a negative value
|
|
|
|
.\" (indicating contention),
|
|
|
|
.\" and will sleep until another process or thread releases
|
|
|
|
.\" the futex and executes the
|
|
|
|
.\" .B FUTEX_WAKE
|
|
|
|
.\" operation.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2015-01-12 12:24:43 +00:00
|
|
|
.BR FUTEX_WAKE " (since Linux 2.6.0)"
|
|
|
|
.\" Strictly speaking, since Linux 2.5.x
|
2015-01-12 13:01:22 +00:00
|
|
|
This operation wakes at most
|
|
|
|
.I val
|
2015-03-02 16:33:18 +00:00
|
|
|
of the waiters that are waiting (e.g., inside
|
2015-01-12 13:01:22 +00:00
|
|
|
.BR FUTEX_WAIT )
|
2015-03-02 16:33:18 +00:00
|
|
|
on the futex word at the address
|
2015-01-12 13:01:22 +00:00
|
|
|
.IR uaddr .
|
|
|
|
Most commonly,
|
|
|
|
.I val
|
|
|
|
is specified as either 1 (wake up a single waiter) or
|
|
|
|
.BR INT_MAX
|
|
|
|
(wake up all waiters).
|
2015-01-13 08:25:04 +00:00
|
|
|
No guarantee is provided about which waiters are awoken
|
|
|
|
(e.g., a waiter with a higher scheduling priority is not guaranteed
|
|
|
|
to be awoken in preference to a waiter with a lower priority).
|
2014-06-04 07:48:23 +00:00
|
|
|
|
2004-11-03 13:51:07 +00:00
|
|
|
The arguments
|
|
|
|
.IR timeout ,
|
2015-01-15 05:18:56 +00:00
|
|
|
.IR uaddr2 ,
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
|
|
|
.I val3
|
|
|
|
are ignored.
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" FIXME . (Torvald) I think we should remove this. Or maybe adapt to
|
|
|
|
.\" a different example.
|
|
|
|
.\"
|
2015-03-28 08:47:43 +00:00
|
|
|
.\" For
|
|
|
|
.\" .BR futex (7),
|
|
|
|
.\" this is executed if incrementing the count showed that
|
|
|
|
.\" there were waiters,
|
|
|
|
.\" once the futex value has been set to 1
|
|
|
|
.\" (indicating that it is available).
|
|
|
|
.\"
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" How does "incrementing the count show that there were waiters"?
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-13 15:47:22 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_FD " (from Linux 2.6.0 up to and including Linux 2.6.25)"
|
|
|
|
.\" Strictly speaking, from Linux 2.5.x to 2.6.25
|
2015-03-28 08:47:43 +00:00
|
|
|
This operation creates a file descriptor that is associated with
|
|
|
|
the futex at
|
2015-01-13 15:47:22 +00:00
|
|
|
.IR uaddr .
|
2015-01-17 05:53:07 +00:00
|
|
|
The caller must close the returned file descriptor after use.
|
|
|
|
When another process or thread performs a
|
2015-01-13 15:47:22 +00:00
|
|
|
.BR FUTEX_WAKE
|
2015-03-02 16:33:18 +00:00
|
|
|
on the futex word, the file descriptor indicates as being readable with
|
2015-01-13 15:47:22 +00:00
|
|
|
.BR select (2),
|
|
|
|
.BR poll (2),
|
|
|
|
and
|
|
|
|
.BR epoll (7)
|
|
|
|
|
2015-01-17 06:00:14 +00:00
|
|
|
The file descriptor can be used to obtain asynchronous notifications: if
|
2015-01-13 15:47:22 +00:00
|
|
|
.I val
|
2015-08-09 08:38:40 +00:00
|
|
|
is nonzero, then, when another process or thread executes a
|
2015-01-13 15:47:22 +00:00
|
|
|
.BR FUTEX_WAKE ,
|
|
|
|
the caller will receive the signal number that was passed in
|
|
|
|
.IR val .
|
|
|
|
|
|
|
|
The arguments
|
|
|
|
.IR timeout ,
|
|
|
|
.I uaddr2
|
|
|
|
and
|
|
|
|
.I val3
|
|
|
|
are ignored.
|
|
|
|
|
|
|
|
Because it was inherently racy,
|
|
|
|
.B FUTEX_FD
|
|
|
|
has been removed
|
|
|
|
.\" commit 82af7aca56c67061420d618cc5a30f0fd4106b80
|
|
|
|
from Linux 2.6.26 onward.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-13 15:47:22 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_REQUEUE " (since Linux 2.6.0)"
|
|
|
|
This operation performs the same task as
|
2015-07-30 07:17:53 +00:00
|
|
|
.BR FUTEX_CMP_REQUEUE
|
|
|
|
(see below), except that no check is made using the value in
|
2015-01-13 15:47:22 +00:00
|
|
|
.IR val3 .
|
|
|
|
(The argument
|
|
|
|
.I val3
|
|
|
|
is ignored.)
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-13 15:47:22 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_CMP_REQUEUE " (since Linux 2.6.7)"
|
2015-03-02 16:33:18 +00:00
|
|
|
This operation first checks whether the location
|
2015-01-13 15:47:22 +00:00
|
|
|
.I uaddr
|
|
|
|
still contains the value
|
|
|
|
.IR val3 .
|
|
|
|
If not, the operation fails with the error
|
|
|
|
.BR EAGAIN .
|
2015-03-02 16:33:18 +00:00
|
|
|
Otherwise, the operation wakes up a maximum of
|
2015-01-13 15:47:22 +00:00
|
|
|
.I val
|
|
|
|
waiters that are waiting on the futex at
|
|
|
|
.IR uaddr .
|
|
|
|
If there are more than
|
|
|
|
.I val
|
|
|
|
waiters, then the remaining waiters are removed
|
|
|
|
from the wait queue of the source futex at
|
|
|
|
.I uaddr
|
|
|
|
and added to the wait queue of the target futex at
|
|
|
|
.IR uaddr2 .
|
|
|
|
The
|
2015-01-15 12:39:09 +00:00
|
|
|
.I val2
|
2015-01-15 12:54:20 +00:00
|
|
|
argument specifies an upper limit on the number of waiters
|
2015-01-13 15:47:22 +00:00
|
|
|
that are requeued to the futex at
|
2015-01-15 12:39:09 +00:00
|
|
|
.IR uaddr2 .
|
2015-01-13 15:47:22 +00:00
|
|
|
|
2015-07-27 11:31:38 +00:00
|
|
|
.\" FIXME(Torvald) Is the following correct? Or is just the decision
|
|
|
|
.\" which threads to wake or requeue part of the atomic operation?
|
2015-03-02 16:33:18 +00:00
|
|
|
The load from
|
|
|
|
.I uaddr
|
2015-03-28 08:47:43 +00:00
|
|
|
is an atomic memory access (i.e., using atomic machine instructions of
|
|
|
|
the respective architecture).
|
2015-03-03 06:22:31 +00:00
|
|
|
This load, the comparison with
|
2015-03-02 16:33:18 +00:00
|
|
|
.IR val3 ,
|
2015-03-28 08:47:43 +00:00
|
|
|
and the requeueing of any waiters are performed atomically and totally
|
|
|
|
ordered with respect to other operations on the same futex word.
|
2015-10-08 10:17:59 +00:00
|
|
|
.\" Notes from a f2f conversation with Thomas Gleixner (Aug 2015): ###
|
|
|
|
.\" The operation is serialized with respect to operations on both
|
|
|
|
.\" source and target futex. No other waiter can enqueue itself
|
|
|
|
.\" for waiting and no other waiter can dequeue itself because of
|
|
|
|
.\" a timeout or signal.
|
2015-03-02 16:33:18 +00:00
|
|
|
|
2015-01-13 15:47:22 +00:00
|
|
|
Typical values to specify for
|
|
|
|
.I val
|
2016-02-02 20:50:47 +00:00
|
|
|
are 0 or 1.
|
2015-01-13 15:47:22 +00:00
|
|
|
(Specifying
|
|
|
|
.BR INT_MAX
|
|
|
|
is not useful, because it would make the
|
|
|
|
.BR FUTEX_CMP_REQUEUE
|
|
|
|
operation equivalent to
|
|
|
|
.BR FUTEX_WAKE .)
|
2015-01-15 12:54:20 +00:00
|
|
|
The limit value specified via
|
2015-01-15 12:39:09 +00:00
|
|
|
.I val2
|
|
|
|
is typically either 1 or
|
2015-01-13 15:47:22 +00:00
|
|
|
.BR INT_MAX .
|
|
|
|
(Specifying the argument as 0 is not useful, because it would make the
|
|
|
|
.BR FUTEX_CMP_REQUEUE
|
|
|
|
operation equivalent to
|
|
|
|
.BR FUTEX_WAIT .)
|
2015-07-30 12:18:23 +00:00
|
|
|
|
|
|
|
The
|
|
|
|
.B FUTEX_CMP_REQUEUE
|
|
|
|
operation was added as a replacement for the earlier
|
|
|
|
.BR FUTEX_REQUEUE .
|
|
|
|
The difference is that the check of the value at
|
|
|
|
.I uaddr
|
|
|
|
can be used to ensure that requeueing happens only under certain
|
|
|
|
conditions, which allows race conditions to be avoided in certain use cases.
|
2015-07-30 12:19:40 +00:00
|
|
|
.\" But, as Rich Felker points out, there remain valid use cases for
|
2015-07-30 12:18:23 +00:00
|
|
|
.\" FUTEX_REQUEUE, for example, when the calling thread is requeuing
|
|
|
|
.\" the target(s) to a lock that the calling thread owns
|
|
|
|
.\" From: Rich Felker <dalias@libc.org>
|
|
|
|
.\" Date: Wed, 29 Oct 2014 22:43:17 -0400
|
|
|
|
.\" To: Darren Hart <dvhart@infradead.org>
|
|
|
|
.\" CC: libc-alpha@sourceware.org, ...
|
|
|
|
.\" Subject: Re: Add futex wrapper to glibc?
|
|
|
|
|
|
|
|
Both
|
|
|
|
.BR FUTEX_REQUEUE
|
|
|
|
and
|
|
|
|
.BR FUTEX_CMP_REQUEUE
|
|
|
|
can be used to avoid "thundering herd" wake-ups that could occur when using
|
|
|
|
.B FUTEX_WAKE
|
|
|
|
in cases where all of the waiters that are woken need to acquire
|
|
|
|
another futex.
|
|
|
|
Consider the following scenario,
|
|
|
|
where multiple waiter threads are waiting on B,
|
|
|
|
a wait queue implemented using a futex:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
lock(A)
|
|
|
|
while (!check_value(V)) {
|
|
|
|
unlock(A);
|
|
|
|
block_on(B);
|
|
|
|
lock(A);
|
|
|
|
};
|
|
|
|
unlock(A);
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
If a waker thread used
|
|
|
|
.BR FUTEX_WAKE ,
|
|
|
|
then all waiters waiting on B would be woken up,
|
2016-01-04 15:59:35 +00:00
|
|
|
and they would all try to acquire lock A.
|
2015-07-30 12:18:23 +00:00
|
|
|
However, waking all of the threads in this manner would be pointless because
|
|
|
|
all except one of the threads would immediately block on lock A again.
|
|
|
|
By contrast, a requeue operation wakes just one waiter and moves
|
|
|
|
the other waiters to lock A,
|
|
|
|
and when the woken waiter unlocks A then the next waiter can proceed.
|
2015-01-15 19:50:33 +00:00
|
|
|
.\"
|
2015-01-15 14:14:31 +00:00
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2015-01-12 09:27:13 +00:00
|
|
|
.BR FUTEX_WAKE_OP " (since Linux 2.6.14)"
|
|
|
|
.\" commit 4732efbeb997189d9f9b04708dc26bf8613ed721
|
2015-01-12 14:38:13 +00:00
|
|
|
.\" Author: Jakub Jelinek <jakub@redhat.com>
|
|
|
|
.\" Date: Tue Sep 6 15:16:25 2005 -0700
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" FIXME. (Torvald) The glibc condvar implementation is currently being
|
2015-03-28 08:47:43 +00:00
|
|
|
.\" revised (e.g., to not use an internal lock anymore).
|
|
|
|
.\" It is probably more future-proof to remove this paragraph.
|
2015-07-27 11:31:38 +00:00
|
|
|
.\" [Torvald, do you have an update here?]
|
2015-01-12 14:38:13 +00:00
|
|
|
This operation was added to support some user-space use cases
|
|
|
|
where more than one futex must be handled at the same time.
|
|
|
|
The most notable example is the implementation of
|
|
|
|
.BR pthread_cond_signal (3),
|
|
|
|
which requires operations on two futexes,
|
|
|
|
the one used to implement the mutex and the one used in the implementation
|
|
|
|
of the wait queue associated with the condition variable.
|
|
|
|
.BR FUTEX_WAKE_OP
|
|
|
|
allows such cases to be implemented without leading to
|
|
|
|
high rates of contention and context switching.
|
|
|
|
|
|
|
|
The
|
2015-12-15 15:47:52 +00:00
|
|
|
.BR FUTEX_WAKE_OP
|
2015-07-27 10:58:38 +00:00
|
|
|
operation is equivalent to executing the following code atomically
|
2015-03-28 08:47:43 +00:00
|
|
|
and totally ordered with respect to other futex operations on
|
|
|
|
any of the two supplied futex words:
|
2015-01-12 14:38:13 +00:00
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
int oldval = *(int *) uaddr2;
|
|
|
|
*(int *) uaddr2 = oldval \fIop\fP \fIoparg\fP;
|
|
|
|
futex(uaddr, FUTEX_WAKE, val, 0, 0, 0);
|
|
|
|
if (oldval \fIcmp\fP \fIcmparg\fP)
|
2015-01-15 12:39:09 +00:00
|
|
|
futex(uaddr2, FUTEX_WAKE, val2, 0, 0, 0);
|
2015-01-12 14:38:13 +00:00
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
In other words,
|
2015-12-15 15:47:52 +00:00
|
|
|
.BR FUTEX_WAKE_OP
|
2015-01-12 14:38:13 +00:00
|
|
|
does the following:
|
|
|
|
.RS
|
|
|
|
.IP * 3
|
2015-03-02 16:33:18 +00:00
|
|
|
saves the original value of the futex word at
|
|
|
|
.IR uaddr2
|
|
|
|
and performs an operation to modify the value of the futex at
|
2015-01-12 14:38:13 +00:00
|
|
|
.IR uaddr2 ;
|
2015-03-28 08:47:43 +00:00
|
|
|
this is an atomic read-modify-write memory access (i.e., using atomic
|
|
|
|
machine instructions of the respective architecture)
|
2015-01-12 14:38:13 +00:00
|
|
|
.IP *
|
|
|
|
wakes up a maximum of
|
|
|
|
.I val
|
2015-03-02 16:33:18 +00:00
|
|
|
waiters on the futex for the futex word at
|
2015-01-12 14:38:13 +00:00
|
|
|
.IR uaddr ;
|
|
|
|
and
|
|
|
|
.IP *
|
2015-03-28 08:47:43 +00:00
|
|
|
dependent on the results of a test of the original value of the
|
|
|
|
futex word at
|
2015-01-12 14:38:13 +00:00
|
|
|
.IR uaddr2 ,
|
|
|
|
wakes up a maximum of
|
2015-01-15 12:39:09 +00:00
|
|
|
.I val2
|
2015-03-02 16:33:18 +00:00
|
|
|
waiters on the futex for the futex word at
|
2015-01-12 14:38:13 +00:00
|
|
|
.IR uaddr2 .
|
|
|
|
.RE
|
|
|
|
.IP
|
|
|
|
The operation and comparison that are to be performed are encoded
|
|
|
|
in the bits of the argument
|
|
|
|
.IR val3 .
|
|
|
|
Pictorially, the encoding is:
|
|
|
|
|
2015-01-15 05:22:35 +00:00
|
|
|
.in +8n
|
2015-01-12 14:38:13 +00:00
|
|
|
.nf
|
2015-01-15 05:22:35 +00:00
|
|
|
+---+---+-----------+-----------+
|
|
|
|
|op |cmp| oparg | cmparg |
|
|
|
|
+---+---+-----------+-----------+
|
|
|
|
4 4 12 12 <== # of bits
|
2015-01-12 14:38:13 +00:00
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
Expressed in code, the encoding is:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
#define FUTEX_OP(op, oparg, cmp, cmparg) \\
|
|
|
|
(((op & 0xf) << 28) | \\
|
|
|
|
((cmp & 0xf) << 24) | \\
|
|
|
|
((oparg & 0xfff) << 12) | \\
|
|
|
|
(cmparg & 0xfff))
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
In the above,
|
|
|
|
.I op
|
|
|
|
and
|
|
|
|
.I cmp
|
|
|
|
are each one of the codes listed below.
|
|
|
|
The
|
|
|
|
.I oparg
|
|
|
|
and
|
|
|
|
.I cmparg
|
|
|
|
components are literal numeric values, except as noted below.
|
|
|
|
|
|
|
|
The
|
|
|
|
.I op
|
|
|
|
component has one of the following values:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
FUTEX_OP_SET 0 /* uaddr2 = oparg; */
|
|
|
|
FUTEX_OP_ADD 1 /* uaddr2 += oparg; */
|
|
|
|
FUTEX_OP_OR 2 /* uaddr2 |= oparg; */
|
|
|
|
FUTEX_OP_ANDN 3 /* uaddr2 &= ~oparg; */
|
|
|
|
FUTEX_OP_XOR 4 /* uaddr2 ^= oparg; */
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
In addition, bit-wise ORing the following value into
|
|
|
|
.I op
|
|
|
|
causes
|
|
|
|
.IR "(1\ <<\ oparg)"
|
|
|
|
to be used as the operand:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
FUTEX_OP_ARG_SHIFT 8 /* Use (1 << oparg) as operand */
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
The
|
|
|
|
.I cmp
|
|
|
|
field is one of the following:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
FUTEX_OP_CMP_EQ 0 /* if (oldval == cmparg) wake */
|
|
|
|
FUTEX_OP_CMP_NE 1 /* if (oldval != cmparg) wake */
|
|
|
|
FUTEX_OP_CMP_LT 2 /* if (oldval < cmparg) wake */
|
|
|
|
FUTEX_OP_CMP_LE 3 /* if (oldval <= cmparg) wake */
|
|
|
|
FUTEX_OP_CMP_GT 4 /* if (oldval > cmparg) wake */
|
|
|
|
FUTEX_OP_CMP_GE 5 /* if (oldval >= cmparg) wake */
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
|
|
|
|
The return value of
|
|
|
|
.BR FUTEX_WAKE_OP
|
|
|
|
is the sum of the number of waiters woken on the futex
|
|
|
|
.IR uaddr
|
|
|
|
plus the number of waiters woken on the futex
|
|
|
|
.IR uaddr2 .
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
2015-01-13 14:34:17 +00:00
|
|
|
.BR FUTEX_WAIT_BITSET " (since Linux 2.6.25)"
|
|
|
|
.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
|
2015-01-13 15:05:32 +00:00
|
|
|
This operation is like
|
2015-01-13 14:34:17 +00:00
|
|
|
.BR FUTEX_WAIT
|
|
|
|
except that
|
|
|
|
.I val3
|
2016-06-24 07:34:16 +00:00
|
|
|
is used to provide a 32-bit bit mask to the kernel.
|
2016-07-17 16:08:45 +00:00
|
|
|
This bit mask, in which at least one bit must be set,
|
2016-06-24 07:35:44 +00:00
|
|
|
is stored in the kernel-internal state of the waiter.
|
2015-01-13 14:34:17 +00:00
|
|
|
See the description of
|
|
|
|
.BR FUTEX_WAKE_BITSET
|
|
|
|
for further details.
|
|
|
|
|
2016-06-23 10:43:51 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is not NULL, the structure it points to specifies
|
|
|
|
an absolute timeout for the wait operation.
|
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is NULL, the operation can block indefinitely.
|
|
|
|
|
|
|
|
|
2015-01-13 14:34:17 +00:00
|
|
|
The
|
|
|
|
.I uaddr2
|
|
|
|
argument is ignored.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-13 14:34:17 +00:00
|
|
|
.TP
|
2015-01-12 09:27:13 +00:00
|
|
|
.BR FUTEX_WAKE_BITSET " (since Linux 2.6.25)"
|
|
|
|
.\" commit cd689985cf49f6ff5c8eddc48d98b9d581d9475d
|
2015-01-13 14:36:37 +00:00
|
|
|
This operation is the same as
|
|
|
|
.BR FUTEX_WAKE
|
|
|
|
except that the
|
2015-12-29 12:51:32 +00:00
|
|
|
.I val3
|
2015-12-19 05:10:00 +00:00
|
|
|
argument is used to provide a 32-bit bit mask to the kernel.
|
2016-06-24 07:35:44 +00:00
|
|
|
This bit mask, in which at least one bit must be set,
|
|
|
|
is used to select which waiters should be woken up.
|
2015-12-19 05:10:00 +00:00
|
|
|
The selection is done by a bit-wise AND of the "wake" bit mask
|
2015-01-13 14:48:51 +00:00
|
|
|
(i.e., the value in
|
|
|
|
.IR val3 )
|
2015-12-19 05:10:00 +00:00
|
|
|
and the bit mask which is stored in the kernel-internal
|
|
|
|
state of the waiter (the "wait" bit mask that is set using
|
2015-01-13 14:48:51 +00:00
|
|
|
.BR FUTEX_WAIT_BITSET ).
|
|
|
|
All of the waiters for which the result of the AND is nonzero are woken up;
|
|
|
|
the remaining waiters are left sleeping.
|
|
|
|
|
2015-01-13 15:29:01 +00:00
|
|
|
The effect of
|
|
|
|
.BR FUTEX_WAIT_BITSET
|
|
|
|
and
|
|
|
|
.BR FUTEX_WAKE_BITSET
|
2015-01-23 13:27:32 +00:00
|
|
|
is to allow selective wake-ups among multiple waiters that are blocked
|
|
|
|
on the same futex.
|
2015-07-30 13:43:54 +00:00
|
|
|
However, note that, depending on the use case,
|
2015-12-19 05:10:00 +00:00
|
|
|
employing this bit-mask multiplexing feature on a
|
2015-07-30 13:43:54 +00:00
|
|
|
futex can be less efficient than simply using multiple futexes,
|
2015-12-19 05:10:00 +00:00
|
|
|
because employing bit-mask multiplexing requires the kernel
|
2015-01-13 15:29:01 +00:00
|
|
|
to check all waiters on a futex,
|
|
|
|
including those that are not interested in being woken up
|
2015-12-19 05:10:00 +00:00
|
|
|
(i.e., they do not have the relevant bit set in their "wait" bit mask).
|
2015-01-13 15:29:01 +00:00
|
|
|
.\" According to http://locklessinc.com/articles/futex_cheat_sheet/:
|
|
|
|
.\"
|
|
|
|
.\" "The original reason for the addition of these extensions
|
|
|
|
.\" was to improve the performance of pthread read-write locks
|
|
|
|
.\" in glibc. However, the pthreads library no longer uses the
|
|
|
|
.\" same locking algorithm, and these extensions are not used
|
|
|
|
.\" without the bitset parameter being all ones.
|
2015-12-29 12:51:32 +00:00
|
|
|
.\"
|
2015-01-13 15:29:01 +00:00
|
|
|
.\" The page goes on to note that the FUTEX_WAIT_BITSET operation
|
2015-12-19 05:10:00 +00:00
|
|
|
.\" is nevertheless used (with a bit mask of all ones) in order to
|
2015-01-13 15:29:01 +00:00
|
|
|
.\" obtain the absolute timeout functionality that is useful
|
|
|
|
.\" for efficiently implementing Pthreads APIs (which use absolute
|
|
|
|
.\" timeouts); FUTEX_WAIT provides only relative timeouts.
|
|
|
|
|
2016-06-24 08:00:25 +00:00
|
|
|
The constant
|
|
|
|
.BR FUTEX_BITSET_MATCH_ANY ,
|
|
|
|
which corresponds to all 32 bits set in the bit mask, can be used as the
|
|
|
|
.I val3
|
|
|
|
argument for
|
|
|
|
.BR FUTEX_WAIT_BITSET
|
2015-01-13 14:48:51 +00:00
|
|
|
and
|
2016-06-24 08:00:25 +00:00
|
|
|
.BR FUTEX_WAKE_BITSET .
|
|
|
|
Other than differences in the handling of the
|
2015-01-13 14:48:51 +00:00
|
|
|
.I timeout
|
2016-06-24 08:00:25 +00:00
|
|
|
argument, the
|
2015-01-23 13:27:32 +00:00
|
|
|
.BR FUTEX_WAIT
|
2016-06-24 08:00:25 +00:00
|
|
|
operation is equivalent to
|
2015-01-23 13:27:32 +00:00
|
|
|
.BR FUTEX_WAIT_BITSET
|
2016-06-24 08:00:25 +00:00
|
|
|
with
|
|
|
|
.IR val3
|
|
|
|
specified as
|
|
|
|
.BR FUTEX_BITSET_MATCH_ANY ;
|
|
|
|
that is, allow a wake-up by any waker.
|
|
|
|
The
|
|
|
|
.BR FUTEX_WAKE
|
|
|
|
operation is equivalent to
|
2015-01-23 13:27:32 +00:00
|
|
|
.BR FUTEX_WAKE_BITSET
|
2016-06-24 08:00:25 +00:00
|
|
|
with
|
|
|
|
.IR val3
|
|
|
|
specified as
|
|
|
|
.BR FUTEX_BITSET_MATCH_ANY ;
|
|
|
|
that is, wake up any waiter(s).
|
|
|
|
|
|
|
|
The
|
|
|
|
.I uaddr2
|
|
|
|
and
|
|
|
|
.I timeout
|
|
|
|
arguments are ignored.
|
2015-01-14 12:52:46 +00:00
|
|
|
.\"
|
2015-01-15 14:14:31 +00:00
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2015-01-14 12:52:46 +00:00
|
|
|
.\"
|
|
|
|
.SS Priority-inheritance futexes
|
2015-01-14 14:42:05 +00:00
|
|
|
Linux supports priority-inheritance (PI) futexes in order to handle
|
|
|
|
priority-inversion problems that can be encountered with
|
|
|
|
normal futex locks.
|
2015-01-16 20:03:25 +00:00
|
|
|
Priority inversion is the problem that occurs when a high-priority
|
2015-01-17 05:53:07 +00:00
|
|
|
task is blocked waiting to acquire a lock held by a low-priority task,
|
|
|
|
while tasks at an intermediate priority continuously preempt
|
|
|
|
the low-priority task from the CPU.
|
|
|
|
Consequently, the low-priority task makes no progress toward
|
|
|
|
releasing the lock, and the high-priority task remains blocked.
|
2015-01-15 19:57:33 +00:00
|
|
|
|
2015-01-16 20:25:04 +00:00
|
|
|
Priority inheritance is a mechanism for dealing with
|
|
|
|
the priority-inversion problem.
|
2015-01-17 05:53:07 +00:00
|
|
|
With this mechanism, when a high-priority task becomes blocked
|
|
|
|
by a lock held by a low-priority task,
|
2015-07-30 13:52:22 +00:00
|
|
|
the priority of the low-priority task is temporarily raised
|
|
|
|
to that of the high-priority task,
|
2015-01-17 05:53:07 +00:00
|
|
|
so that it is not preempted by any intermediate level tasks,
|
2015-01-16 20:25:04 +00:00
|
|
|
and can thus make progress toward releasing the lock.
|
|
|
|
To be effective, priority inheritance must be transitive,
|
2015-01-17 05:53:07 +00:00
|
|
|
meaning that if a high-priority task blocks on a lock
|
2015-08-09 08:38:40 +00:00
|
|
|
held by a lower-priority task that is itself blocked by a lock
|
2015-01-17 05:53:07 +00:00
|
|
|
held by another intermediate-priority task
|
2015-01-16 20:25:04 +00:00
|
|
|
(and so on, for chains of arbitrary length),
|
2015-07-28 08:10:00 +00:00
|
|
|
then both of those tasks
|
2015-01-17 05:53:07 +00:00
|
|
|
(or more generally, all of the tasks in a lock chain)
|
|
|
|
have their priorities raised to be the same as the high-priority task.
|
2015-01-16 20:25:04 +00:00
|
|
|
|
2015-01-18 10:06:04 +00:00
|
|
|
From a user-space perspective,
|
2015-07-30 14:01:56 +00:00
|
|
|
what makes a futex PI-aware is a policy agreement (described below)
|
|
|
|
between user space and the kernel about the value of the futex word,
|
2015-08-08 06:28:17 +00:00
|
|
|
coupled with the use of the PI-futex operations described below.
|
|
|
|
(Unlike the other futex operations described above,
|
|
|
|
the PI-futex operations are designed
|
|
|
|
for the implementation of very specific IPC mechanisms.)
|
|
|
|
.\"
|
2015-01-18 10:06:04 +00:00
|
|
|
.\" Quoting Darren Hart:
|
|
|
|
.\" These opcodes paired with the PI futex value policy (described below)
|
|
|
|
.\" defines a "futex" as PI aware. These were created very specifically
|
|
|
|
.\" in support of PI pthread_mutexes, so it makes a lot more sense to
|
|
|
|
.\" talk about a PI aware pthread_mutex, than a PI aware futex, since
|
|
|
|
.\" there is a lot of policy and scaffolding that has to be built up
|
|
|
|
.\" around it to use it properly (this is what a PI pthread_mutex is).
|
|
|
|
|
2015-07-30 13:43:54 +00:00
|
|
|
.\" mtk: The following text is drawn from the Hart/Guniguntala paper
|
2015-01-27 07:43:43 +00:00
|
|
|
.\" (listed in SEE ALSO), but I have reworded some pieces
|
2016-09-16 15:27:52 +00:00
|
|
|
.\" significantly.
|
2015-01-14 14:12:44 +00:00
|
|
|
.\"
|
2015-07-30 14:03:14 +00:00
|
|
|
The PI-futex operations described below differ from the other
|
2015-03-02 16:33:18 +00:00
|
|
|
futex operations in that they impose policy on the use of the value of the
|
|
|
|
futex word:
|
2015-01-14 14:12:44 +00:00
|
|
|
.IP * 3
|
2015-03-02 16:33:18 +00:00
|
|
|
If the lock is not acquired, the futex word's value shall be 0.
|
2015-01-14 14:12:44 +00:00
|
|
|
.IP *
|
2015-03-28 08:47:43 +00:00
|
|
|
If the lock is acquired, the futex word's value shall
|
|
|
|
be the thread ID (TID;
|
2015-03-02 16:33:18 +00:00
|
|
|
see
|
2015-01-14 14:12:44 +00:00
|
|
|
.BR gettid (2))
|
|
|
|
of the owning thread.
|
|
|
|
.IP *
|
|
|
|
If the lock is owned and there are threads contending for the lock,
|
|
|
|
then the
|
|
|
|
.B FUTEX_WAITERS
|
2015-03-02 16:33:18 +00:00
|
|
|
bit shall be set in the futex word's value; in other words, this value is:
|
2015-01-14 14:12:44 +00:00
|
|
|
|
|
|
|
FUTEX_WAITERS | TID
|
2015-08-08 06:28:17 +00:00
|
|
|
.IP
|
|
|
|
(Note that is invalid for a PI futex word to have no owner and
|
|
|
|
.BR FUTEX_WAITERS
|
|
|
|
set.)
|
2015-01-14 14:12:44 +00:00
|
|
|
.PP
|
|
|
|
With this policy in place,
|
2015-07-28 09:09:15 +00:00
|
|
|
a user-space application can acquire an unacquired
|
2015-08-08 06:28:17 +00:00
|
|
|
lock or release a lock using atomic instructions executed in user mode
|
2015-07-28 09:09:15 +00:00
|
|
|
(e.g., a compare-and-swap operation such as
|
2015-01-14 14:42:05 +00:00
|
|
|
.I cmpxchg
|
|
|
|
on the x86 architecture).
|
2015-03-28 08:47:43 +00:00
|
|
|
Acquiring a lock simply consists of using compare-and-swap to atomically
|
|
|
|
set the futex word's value to the caller's TID if its previous value was 0.
|
2015-03-02 16:33:18 +00:00
|
|
|
Releasing a lock requires using compare-and-swap to set the futex word's
|
|
|
|
value to 0 if the previous value was the expected TID.
|
2015-01-14 14:42:05 +00:00
|
|
|
|
2015-03-02 16:33:18 +00:00
|
|
|
If a futex is already acquired (i.e., has a nonzero value),
|
2015-01-14 14:42:05 +00:00
|
|
|
waiters must employ the
|
2015-01-14 14:12:44 +00:00
|
|
|
.B FUTEX_LOCK_PI
|
|
|
|
operation to acquire the lock.
|
2015-03-02 16:33:18 +00:00
|
|
|
If other threads are waiting for the lock, then the
|
2015-01-14 14:12:44 +00:00
|
|
|
.B FUTEX_WAITERS
|
2015-03-28 08:47:43 +00:00
|
|
|
bit is set in the futex value;
|
|
|
|
in this case, the lock owner must employ the
|
2015-01-14 14:12:44 +00:00
|
|
|
.B FUTEX_UNLOCK_PI
|
2015-01-14 14:42:05 +00:00
|
|
|
operation to release the lock.
|
|
|
|
|
2015-01-14 14:12:44 +00:00
|
|
|
In the cases where callers are forced into the kernel
|
|
|
|
(i.e., required to perform a
|
|
|
|
.BR futex ()
|
2015-04-11 07:07:15 +00:00
|
|
|
call),
|
2015-01-14 14:12:44 +00:00
|
|
|
they then deal directly with a so-called RT-mutex,
|
|
|
|
a kernel locking mechanism which implements the required
|
|
|
|
priority-inheritance semantics.
|
|
|
|
After the RT-mutex is acquired, the futex value is updated accordingly,
|
|
|
|
before the calling thread returns to user space.
|
|
|
|
|
2015-01-15 14:35:50 +00:00
|
|
|
It is important to note
|
2015-07-30 13:43:54 +00:00
|
|
|
.\" tglx (July 2015):
|
2015-08-07 14:31:23 +00:00
|
|
|
.\" If there are multiple waiters on a pi futex then a wake pi operation
|
|
|
|
.\" will wake the first waiter and hand over the lock to this waiter. This
|
|
|
|
.\" includes handing over the rtmutex which represents the futex in the
|
|
|
|
.\" kernel. The strict requirement is that the futex owner and the rtmutex
|
|
|
|
.\" owner must be the same, except for the update period which is
|
|
|
|
.\" serialized by the futex internal locking. That means the kernel must
|
2015-08-21 16:30:00 +00:00
|
|
|
.\" update the user-space value prior to returning to user space
|
2015-03-02 16:33:18 +00:00
|
|
|
that the kernel will update the futex word's value prior
|
2015-01-14 14:12:44 +00:00
|
|
|
to returning to user space.
|
2015-08-08 06:28:17 +00:00
|
|
|
(This prevents the possibility of the futex word's value ending
|
|
|
|
up in an invalid state, such as having an owner but the value being 0,
|
|
|
|
or having waiters but not having the
|
|
|
|
.B FUTEX_WAITERS
|
|
|
|
bit set.)
|
2015-08-07 14:31:23 +00:00
|
|
|
|
|
|
|
If a futex has an associated RT-mutex in the kernel
|
|
|
|
(i.e., there are blocked waiters)
|
|
|
|
and the owner of the futex/RT-mutex dies unexpectedly,
|
|
|
|
then the kernel cleans up the RT-mutex and hands it over to the next waiter.
|
|
|
|
This in turn requires that the user-space value is updated accordingly.
|
|
|
|
To indicate that this is required, the kernel sets the
|
|
|
|
.B FUTEX_OWNER_DIED
|
|
|
|
bit in the futex word along with the thread ID of the new owner.
|
2015-12-26 08:02:35 +00:00
|
|
|
User space can detect this situation via the presence of the
|
|
|
|
.B FUTEX_OWNER_DIED
|
|
|
|
bit and is then responsible for cleaning up the stale state left over by
|
2015-08-21 16:30:00 +00:00
|
|
|
the dead owner.
|
2015-08-07 14:31:23 +00:00
|
|
|
.\" tglx (July 2015):
|
|
|
|
.\" The FUTEX_OWNER_DIED bit can also be set on uncontended futexes, where
|
|
|
|
.\" the kernel has no state associated. This happens via the robust futex
|
|
|
|
.\" mechanism. In that case the futex value will be set to
|
|
|
|
.\" FUTEX_OWNER_DIED. The robust futex mechanism is also available for non
|
|
|
|
.\" PI futexes.
|
2015-01-14 12:52:46 +00:00
|
|
|
|
2015-08-08 06:28:17 +00:00
|
|
|
PI futexes are operated on by specifying one of the values listed below in
|
|
|
|
.IR futex_op .
|
|
|
|
Note that the PI futex operations must be used as paired operations
|
|
|
|
and are subject to some additional requirements:
|
|
|
|
.IP * 3
|
|
|
|
.B FUTEX_LOCK_PI
|
|
|
|
and
|
|
|
|
.B FUTEX_TRYLOCK_PI
|
|
|
|
pair with
|
|
|
|
.BR FUTEX_UNLOCK_PI.
|
|
|
|
.B FUTEX_UNLOCK_PI
|
|
|
|
must be called only on a futex owned by the calling thread,
|
|
|
|
as defined by the value policy, otherwise the error
|
|
|
|
.B EPERM
|
|
|
|
results.
|
|
|
|
.IP *
|
|
|
|
.B FUTEX_WAIT_REQUEUE_PI
|
|
|
|
pairs with
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI .
|
|
|
|
This must be performed from a non-PI futex to a distinct PI futex
|
|
|
|
(or the error
|
|
|
|
.B EINVAL
|
|
|
|
results).
|
|
|
|
Additionally,
|
|
|
|
.I val
|
|
|
|
(the number of waiters to be woken) must be 1
|
|
|
|
(or the error
|
|
|
|
.B EINVAL
|
|
|
|
results).
|
|
|
|
.P
|
|
|
|
The PI futex operations are as follows:
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_LOCK_PI " (since Linux 2.6.18)"
|
|
|
|
.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
|
2015-12-19 05:21:41 +00:00
|
|
|
This operation is used after an attempt to acquire
|
2015-07-28 09:09:15 +00:00
|
|
|
the lock via an atomic user-mode instruction failed
|
2015-03-02 16:33:18 +00:00
|
|
|
because the futex word has a nonzero value\(emspecifically,
|
2015-07-30 08:19:44 +00:00
|
|
|
because it contained the (PID-namespace-specific) TID of the lock owner.
|
2015-01-14 15:48:55 +00:00
|
|
|
|
2015-03-02 16:33:18 +00:00
|
|
|
The operation checks the value of the futex word at the address
|
2015-01-14 15:48:55 +00:00
|
|
|
.IR uaddr .
|
2015-01-15 14:14:31 +00:00
|
|
|
If the value is 0, then the kernel tries to atomically set
|
|
|
|
the futex value to the caller's TID.
|
2015-08-07 20:41:53 +00:00
|
|
|
If the futex word's value is nonzero,
|
2015-01-14 15:48:55 +00:00
|
|
|
the kernel atomically sets the
|
2015-01-14 08:11:16 +00:00
|
|
|
.B FUTEX_WAITERS
|
2015-01-14 15:48:55 +00:00
|
|
|
bit, which signals the futex owner that it cannot unlock the futex in
|
|
|
|
user space atomically by setting the futex value to 0.
|
2015-08-07 20:41:53 +00:00
|
|
|
.\" tglx (July 2015):
|
|
|
|
.\" The operation here is similar to the FUTEX_WAIT logic. When the user
|
|
|
|
.\" space atomic acquire does not succeed because the futex value was non
|
|
|
|
.\" zero, then the waiter goes into the kernel, takes the kernel internal
|
|
|
|
.\" lock and retries the acquisition under the lock. If the acquisition
|
|
|
|
.\" does not succeed either, then it sets the FUTEX_WAITERS bit, to signal
|
|
|
|
.\" the lock owner that it needs to go into the kernel. Here is the pseudo
|
|
|
|
.\" code:
|
|
|
|
.\"
|
|
|
|
.\" lock(kernel_lock);
|
|
|
|
.\" retry:
|
|
|
|
.\"
|
|
|
|
.\" /*
|
|
|
|
.\" * Owner might have unlocked in userspace before we
|
|
|
|
.\" * were able to set the waiter bit.
|
|
|
|
.\" */
|
|
|
|
.\" if (atomic_acquire(futex) == SUCCESS) {
|
|
|
|
.\" unlock(kernel_lock());
|
|
|
|
.\" return 0;
|
|
|
|
.\" }
|
|
|
|
.\"
|
|
|
|
.\" /*
|
|
|
|
.\" * Owner might have unlocked after the above atomic_acquire()
|
|
|
|
.\" * attempt.
|
|
|
|
.\" */
|
|
|
|
.\" if (atomic_set_waiters_bit(futex) != SUCCESS)
|
|
|
|
.\" goto retry;
|
|
|
|
.\"
|
|
|
|
.\" queue_waiter();
|
|
|
|
.\" unlock(kernel_lock);
|
|
|
|
.\" block();
|
|
|
|
.\"
|
|
|
|
After that, the kernel:
|
|
|
|
.RS
|
|
|
|
.IP 1. 3
|
|
|
|
Tries to find the thread which is associated with the owner TID.
|
|
|
|
.IP 2.
|
|
|
|
Creates or reuses kernel state on behalf of the owner.
|
|
|
|
(If this is the first waiter, there is no kernel state for this
|
|
|
|
futex, so kernel state is created by locking the RT-mutex
|
|
|
|
and the futex owner is made the owner of the RT-mutex.
|
|
|
|
If there are existing waiters, then the existing state is reused.)
|
|
|
|
.IP 3.
|
2015-08-09 08:38:40 +00:00
|
|
|
Attaches the waiter to the futex
|
2015-08-07 20:41:53 +00:00
|
|
|
(i.e., the waiter is enqueued on the RT-mutex waiter list).
|
|
|
|
.RE
|
|
|
|
.IP
|
2015-07-30 13:43:54 +00:00
|
|
|
If more than one waiter exists,
|
|
|
|
the enqueueing of the waiter is in descending priority order.
|
|
|
|
(For information on priority ordering, see the discussion of the
|
|
|
|
.BR SCHED_DEADLINE ,
|
|
|
|
.BR SCHED_FIFO ,
|
|
|
|
and
|
|
|
|
.BR SCHED_RR
|
|
|
|
scheduling policies in
|
|
|
|
.BR sched (7).)
|
|
|
|
The owner inherits either the waiter's CPU bandwidth
|
|
|
|
(if the waiter is scheduled under the
|
|
|
|
.BR SCHED_DEADLINE
|
|
|
|
policy) or the waiter's priority (if the waiter is scheduled under the
|
|
|
|
.BR SCHED_RR
|
|
|
|
or
|
|
|
|
.BR SCHED_FIFO
|
|
|
|
policy).
|
2015-08-21 16:30:00 +00:00
|
|
|
.\" August 2015:
|
|
|
|
.\" mtk: If the realm is restricted purely to SCHED_OTHER (SCHED_NORMAL)
|
|
|
|
.\" processes, does the nice value come into play also?
|
|
|
|
.\"
|
|
|
|
.\" tglx: No. SCHED_OTHER/NORMAL tasks are handled in FIFO order
|
2015-08-07 20:41:53 +00:00
|
|
|
This inheritance follows the lock chain in the case of nested locking
|
2015-08-09 08:38:40 +00:00
|
|
|
.\" (i.e., task 1 blocks on lock A, held by task 2,
|
|
|
|
.\" while task 2 blocks on lock B, held by task 3)
|
2015-08-07 20:41:53 +00:00
|
|
|
and performs deadlock detection.
|
|
|
|
|
2015-01-14 08:11:16 +00:00
|
|
|
The
|
|
|
|
.I timeout
|
2015-01-14 12:47:33 +00:00
|
|
|
argument provides a timeout for the lock attempt.
|
2016-06-23 10:43:51 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is not NULL, the structure it points to specifies
|
|
|
|
an absolute timeout, measured against the
|
2015-01-14 12:47:33 +00:00
|
|
|
.BR CLOCK_REALTIME
|
|
|
|
clock.
|
2016-07-07 08:12:58 +00:00
|
|
|
.\" 2016-07-07 response from Thomas Gleixner on LKML:
|
|
|
|
.\" From: Thomas Gleixner <tglx@linutronix.de>
|
|
|
|
.\" Date: 6 July 2016 at 20:57
|
|
|
|
.\" Subject: Re: futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op
|
2016-07-17 16:08:45 +00:00
|
|
|
.\"
|
2016-07-07 08:12:58 +00:00
|
|
|
.\" On Thu, 23 Jun 2016, Michael Kerrisk (man-pages) wrote:
|
|
|
|
.\" > On 06/23/2016 08:28 PM, Darren Hart wrote:
|
|
|
|
.\" > > And as a follow-on, what is the reason for FUTEX_LOCK_PI only using
|
|
|
|
.\" > > CLOCK_REALTIME? It seems reasonable to me that a user may want to wait a
|
|
|
|
.\" > > specific amount of time, regardless of wall time.
|
|
|
|
.\" >
|
|
|
|
.\" > Yes, that's another weird inconsistency.
|
2016-07-17 16:08:45 +00:00
|
|
|
.\"
|
2016-07-07 08:12:58 +00:00
|
|
|
.\" The reason is that phtread_mutex_timedlock() uses absolute timeouts based on
|
|
|
|
.\" CLOCK_REALTIME. glibc folks asked to make that the default behaviour back
|
|
|
|
.\" then when we added LOCK_PI.
|
2015-01-14 12:47:33 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is NULL, the operation will block indefinitely.
|
2015-01-14 08:11:16 +00:00
|
|
|
|
2015-01-14 08:13:03 +00:00
|
|
|
The
|
2015-01-14 08:11:16 +00:00
|
|
|
.IR uaddr2 ,
|
|
|
|
.IR val ,
|
|
|
|
and
|
|
|
|
.IR val3
|
2015-01-14 08:13:03 +00:00
|
|
|
arguments are ignored.
|
2015-01-14 15:48:55 +00:00
|
|
|
.\"
|
2015-01-15 14:14:31 +00:00
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
2015-01-14 11:11:41 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI " (since Linux 2.6.18)"
|
2015-01-12 09:27:13 +00:00
|
|
|
.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
|
2015-12-15 16:00:04 +00:00
|
|
|
This operation tries to acquire the lock at
|
2015-01-14 11:11:41 +00:00
|
|
|
.IR uaddr .
|
2015-08-07 20:41:53 +00:00
|
|
|
It is invoked when a user-space atomic acquire did not
|
|
|
|
succeed because the futex word was not 0.
|
|
|
|
|
2015-12-26 08:02:35 +00:00
|
|
|
Because the kernel has access to more state information than user space,
|
|
|
|
acquisition of the lock might succeed if performed by the
|
|
|
|
kernel in cases where the futex word
|
|
|
|
(i.e., the state information accessible to use-space) contains stale state
|
2015-08-07 20:41:53 +00:00
|
|
|
.RB ( FUTEX_WAITERS
|
|
|
|
and/or
|
|
|
|
.BR FUTEX_OWNER_DIED ).
|
|
|
|
This can happen when the owner of the futex died.
|
2015-08-21 16:30:00 +00:00
|
|
|
User space cannot handle this condition in a race-free manner,
|
|
|
|
but the kernel can fix this up and acquire the futex.
|
2015-10-08 10:17:59 +00:00
|
|
|
.\" Paraphrasing a f2f conversation with Thomas Gleixner about the
|
|
|
|
.\" above point (Aug 2015): ###
|
|
|
|
.\" There is a rare possibility of a race condition involving an
|
|
|
|
.\" uncontended futex with no owner, but with waiters. The
|
|
|
|
.\" kernel-user-space contract is that if a futex is nonzero, you must
|
|
|
|
.\" go into kernel. The futex was owned by a task, and that task dies
|
|
|
|
.\" but there are no waiters, so the futex value is non zero.
|
|
|
|
.\" Therefore, the next locker has to go into the kernel,
|
|
|
|
.\" so that the kernel has a chance to clean up. (CMXCH on zero
|
|
|
|
.\" in user space would fail, so kernel has to clean up.)
|
2015-12-26 08:02:35 +00:00
|
|
|
.\" Darren Hart (Oct 2015):
|
|
|
|
.\" The trylock in the kernel has more state, so it can independently
|
|
|
|
.\" verify the flags that userspace must trust implicitly.
|
2015-01-14 16:39:01 +00:00
|
|
|
|
|
|
|
The
|
|
|
|
.IR uaddr2 ,
|
|
|
|
.IR val ,
|
|
|
|
.IR timeout ,
|
|
|
|
and
|
|
|
|
.IR val3
|
|
|
|
arguments are ignored.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
2015-01-14 11:11:41 +00:00
|
|
|
.BR FUTEX_UNLOCK_PI " (since Linux 2.6.18)"
|
2015-01-12 09:27:13 +00:00
|
|
|
.\" commit c87e2837be82df479a6bae9f155c43516d2feebc
|
2015-01-15 20:07:26 +00:00
|
|
|
This operation wakes the top priority waiter that is waiting in
|
2015-01-14 11:24:02 +00:00
|
|
|
.B FUTEX_LOCK_PI
|
|
|
|
on the futex address provided by the
|
|
|
|
.I uaddr
|
|
|
|
argument.
|
|
|
|
|
2015-08-21 16:30:00 +00:00
|
|
|
This is called when the user-space value at
|
2015-01-14 11:24:02 +00:00
|
|
|
.I uaddr
|
|
|
|
cannot be changed atomically from a TID (of the owner) to 0.
|
|
|
|
|
|
|
|
The
|
|
|
|
.IR uaddr2 ,
|
|
|
|
.IR val ,
|
|
|
|
.IR timeout ,
|
|
|
|
and
|
|
|
|
.IR val3
|
2015-01-14 16:37:51 +00:00
|
|
|
arguments are ignored.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI " (since Linux 2.6.31)"
|
|
|
|
.\" commit 52400ba946759af28442dee6265c5c0180ac7122
|
2015-01-14 17:02:54 +00:00
|
|
|
This operation is a PI-aware variant of
|
|
|
|
.BR FUTEX_CMP_REQUEUE .
|
|
|
|
It requeues waiters that are blocked via
|
|
|
|
.B FUTEX_WAIT_REQUEUE_PI
|
|
|
|
on
|
|
|
|
.I uaddr
|
|
|
|
from a non-PI source futex
|
|
|
|
.RI ( uaddr )
|
|
|
|
to a PI target futex
|
|
|
|
.RI ( uaddr2 ).
|
|
|
|
|
2015-01-14 17:19:05 +00:00
|
|
|
As with
|
|
|
|
.BR FUTEX_CMP_REQUEUE ,
|
|
|
|
this operation wakes up a maximum of
|
|
|
|
.I val
|
|
|
|
waiters that are waiting on the futex at
|
|
|
|
.IR uaddr .
|
|
|
|
However, for
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI ,
|
|
|
|
.I val
|
2015-01-15 13:32:34 +00:00
|
|
|
is required to be 1
|
2015-01-15 20:08:24 +00:00
|
|
|
(since the main point is to avoid a thundering herd).
|
2015-01-14 17:19:05 +00:00
|
|
|
The remaining waiters are removed from the wait queue of the source futex at
|
|
|
|
.I uaddr
|
|
|
|
and added to the wait queue of the target futex at
|
|
|
|
.IR uaddr2 .
|
2015-01-14 17:02:54 +00:00
|
|
|
|
2015-01-14 17:19:05 +00:00
|
|
|
The
|
2015-01-15 12:39:09 +00:00
|
|
|
.I val2
|
2015-01-15 12:56:40 +00:00
|
|
|
.\" val2 is the cap on the number of requeued waiters.
|
|
|
|
.\" In the glibc pthread_cond_broadcast() implementation, this argument
|
|
|
|
.\" is specified as INT_MAX, and for pthread_cond_signal() it is 0.
|
2015-01-14 17:19:05 +00:00
|
|
|
and
|
2015-01-15 12:39:09 +00:00
|
|
|
.I val3
|
2015-01-14 17:19:05 +00:00
|
|
|
arguments serve the same purposes as for
|
|
|
|
.BR FUTEX_CMP_REQUEUE .
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
2015-07-30 08:19:44 +00:00
|
|
|
.\" The page at http://locklessinc.com/articles/futex_cheat_sheet/
|
2015-01-14 17:37:27 +00:00
|
|
|
.\" notes that "priority-inheritance Futex to priority-inheritance
|
2015-07-30 08:19:44 +00:00
|
|
|
.\" Futex requeues are currently unsupported". However, probably
|
|
|
|
.\" the page does not need to say nothing about this, since
|
|
|
|
.\" Thomas Gleixner commented (July 2015): "they never will be
|
|
|
|
.\" supported because they make no sense at all"
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2015-01-12 09:27:13 +00:00
|
|
|
.TP
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI " (since Linux 2.6.31)"
|
|
|
|
.\" commit 52400ba946759af28442dee6265c5c0180ac7122
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
2015-08-07 20:41:53 +00:00
|
|
|
Wait on a non-PI futex at
|
2015-01-15 13:07:55 +00:00
|
|
|
.I uaddr
|
2015-08-07 20:41:53 +00:00
|
|
|
and potentially be requeued (via a
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI
|
|
|
|
operation in another task) onto a PI futex at
|
2015-01-15 13:07:55 +00:00
|
|
|
.IR uaddr2 .
|
|
|
|
The wait operation on
|
|
|
|
.I uaddr
|
2015-08-07 20:41:53 +00:00
|
|
|
is the same as for
|
2015-01-15 13:07:55 +00:00
|
|
|
.BR FUTEX_WAIT .
|
2015-08-07 20:41:53 +00:00
|
|
|
|
2015-01-15 13:07:55 +00:00
|
|
|
The waiter can be removed from the wait on
|
|
|
|
.I uaddr
|
|
|
|
without requeueing on
|
2015-08-07 20:41:53 +00:00
|
|
|
.IR uaddr2
|
|
|
|
via a
|
2015-08-21 16:30:00 +00:00
|
|
|
.BR FUTEX_WAKE
|
2015-08-07 20:41:53 +00:00
|
|
|
operation in another task.
|
|
|
|
In this case, the
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI
|
2015-12-15 16:00:04 +00:00
|
|
|
operation fails with the error
|
|
|
|
.BR EAGAIN .
|
2015-01-15 13:11:15 +00:00
|
|
|
|
2015-01-15 13:17:20 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
2016-06-23 10:43:51 +00:00
|
|
|
is not NULL, the structure it points to specifies
|
|
|
|
an absolute timeout for the wait operation.
|
2015-01-15 13:17:20 +00:00
|
|
|
If
|
|
|
|
.I timeout
|
|
|
|
is NULL, the operation can block indefinitely.
|
|
|
|
|
2015-01-15 13:11:15 +00:00
|
|
|
The
|
|
|
|
.I val3
|
|
|
|
argument is ignored.
|
2015-01-17 09:12:57 +00:00
|
|
|
|
|
|
|
The
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI
|
|
|
|
and
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI
|
|
|
|
were added to support a fairly specific use case:
|
|
|
|
support for priority-inheritance-aware POSIX threads condition variables.
|
|
|
|
The idea is that these operations should always be paired,
|
|
|
|
in order to ensure that user space and the kernel remain in sync.
|
|
|
|
Thus, in the
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI
|
|
|
|
operation, the user-space application pre-specifies the target
|
|
|
|
of the requeue that takes place in the
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI
|
|
|
|
operation.
|
|
|
|
.\"
|
|
|
|
.\" Darren Hart notes that a patch to allow glibc to fully support
|
2015-01-27 07:43:43 +00:00
|
|
|
.\" PI-aware pthreads condition variables has not yet been accepted into
|
2015-01-17 09:12:57 +00:00
|
|
|
.\" glibc. The story is complex, and can be found at
|
|
|
|
.\" https://sourceware.org/bugzilla/show_bug.cgi?id=11588
|
|
|
|
.\" Darren notes that in the meantime, the patch is shipped with various
|
2015-01-27 07:43:43 +00:00
|
|
|
.\" PREEMPT_RT-enabled Linux systems.
|
2015-01-17 09:12:57 +00:00
|
|
|
.\"
|
|
|
|
.\" Related to the preceding, Darren proposed that somewhere, man-pages
|
|
|
|
.\" should document the following point:
|
2015-01-27 07:43:43 +00:00
|
|
|
.\"
|
2015-03-28 08:47:43 +00:00
|
|
|
.\" While the Linux kernel, since 2.6.31, supports requeueing of
|
|
|
|
.\" priority-inheritance (PI) aware mutexes via the
|
|
|
|
.\" FUTEX_WAIT_REQUEUE_PI and FUTEX_CMP_REQUEUE_PI futex operations,
|
|
|
|
.\" the glibc implementation does not yet take full advantage of this.
|
|
|
|
.\" Specifically, the condvar internal data lock remains a non-PI aware
|
|
|
|
.\" mutex, regardless of the type of the pthread_mutex associated with
|
|
|
|
.\" the condvar. This can lead to an unbounded priority inversion on
|
|
|
|
.\" the internal data lock even when associating a PI aware
|
|
|
|
.\" pthread_mutex with a condvar during a pthread_cond*_wait
|
|
|
|
.\" operation. For this reason, it is not recommended to rely on
|
|
|
|
.\" priority inheritance when using pthread condition variables.
|
2015-01-27 07:43:43 +00:00
|
|
|
.\"
|
|
|
|
.\" The problem is that the obvious location for this text is
|
|
|
|
.\" the pthread_cond*wait(3) man page. However, such a man page
|
2015-01-17 09:12:57 +00:00
|
|
|
.\" does not currently exist.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
2015-01-16 20:25:48 +00:00
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH RETURN VALUE
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2015-07-27 10:57:30 +00:00
|
|
|
In the event of an error (and assuming that
|
|
|
|
.BR futex ()
|
|
|
|
was invoked via
|
|
|
|
.BR syscall (2)),
|
|
|
|
all operations return \-1 and set
|
2012-08-13 12:50:26 +00:00
|
|
|
.I errno
|
2015-01-14 09:48:16 +00:00
|
|
|
to indicate the cause of the error.
|
2015-08-08 06:28:59 +00:00
|
|
|
|
2012-08-13 12:50:26 +00:00
|
|
|
The return value on success depends on the operation,
|
|
|
|
as described in the following list:
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAIT
|
2015-03-03 06:22:31 +00:00
|
|
|
Returns 0 if the caller was woken up.
|
2015-03-28 08:47:43 +00:00
|
|
|
Note that a wake-up can also be caused by common futex usage patterns
|
|
|
|
in unrelated code that happened to have previously used the futex word's
|
|
|
|
memory location (e.g., typical futex-based implementations of
|
|
|
|
Pthreads mutexes can cause this under some conditions).
|
|
|
|
Therefore, callers should always conservatively assume that a return
|
|
|
|
value of 0 can mean a spurious wake-up, and use the futex word's value
|
2015-12-19 05:21:41 +00:00
|
|
|
(i.e., the user-space synchronization scheme)
|
|
|
|
to decide whether to continue to block or not.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAKE
|
2015-01-17 05:53:07 +00:00
|
|
|
Returns the number of waiters that were woken up.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_FD
|
|
|
|
Returns the new file descriptor associated with the futex.
|
|
|
|
.TP
|
|
|
|
.B FUTEX_REQUEUE
|
2015-01-17 05:53:07 +00:00
|
|
|
Returns the number of waiters that were woken up.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_CMP_REQUEUE
|
2015-01-17 05:53:07 +00:00
|
|
|
Returns the total number of waiters that were woken up or
|
2015-03-02 16:33:18 +00:00
|
|
|
requeued to the futex for the futex word at
|
2015-01-13 05:40:25 +00:00
|
|
|
.IR uaddr2 .
|
|
|
|
If this value is greater than
|
|
|
|
.IR val ,
|
2015-07-28 09:09:15 +00:00
|
|
|
then the difference is the number of waiters requeued to the futex for the
|
2015-03-28 08:47:43 +00:00
|
|
|
futex word at
|
2015-01-13 05:40:25 +00:00
|
|
|
.IR uaddr2 .
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAKE_OP
|
2015-01-15 10:22:09 +00:00
|
|
|
Returns the total number of waiters that were woken up.
|
2015-03-28 08:47:43 +00:00
|
|
|
This is the sum of the woken waiters on the two futexes for
|
|
|
|
the futex words at
|
2015-01-15 10:22:09 +00:00
|
|
|
.I uaddr
|
|
|
|
and
|
|
|
|
.IR uaddr2 .
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAIT_BITSET
|
2015-03-03 06:22:31 +00:00
|
|
|
Returns 0 if the caller was woken up.
|
|
|
|
See
|
2015-03-02 16:33:18 +00:00
|
|
|
.B FUTEX_WAIT
|
|
|
|
for how to interpret this correctly in practice.
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAKE_BITSET
|
2015-01-17 05:53:07 +00:00
|
|
|
Returns the number of waiters that were woken up.
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_LOCK_PI
|
2015-01-14 11:56:13 +00:00
|
|
|
Returns 0 if the futex was successfully locked.
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_TRYLOCK_PI
|
2015-01-14 11:57:14 +00:00
|
|
|
Returns 0 if the futex was successfully locked.
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_UNLOCK_PI
|
2015-01-14 11:58:28 +00:00
|
|
|
Returns 0 if the futex was successfully unlocked.
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_CMP_REQUEUE_PI
|
2015-01-17 05:53:07 +00:00
|
|
|
Returns the total number of waiters that were woken up or
|
2015-03-02 16:33:18 +00:00
|
|
|
requeued to the futex for the futex word at
|
2015-01-14 12:02:46 +00:00
|
|
|
.IR uaddr2 .
|
|
|
|
If this value is greater than
|
|
|
|
.IR val ,
|
2015-03-28 08:47:43 +00:00
|
|
|
then difference is the number of waiters requeued to the futex for
|
|
|
|
the futex word at
|
2015-01-14 12:02:46 +00:00
|
|
|
.IR uaddr2 .
|
2015-01-14 11:37:55 +00:00
|
|
|
.TP
|
|
|
|
.B FUTEX_WAIT_REQUEUE_PI
|
2015-03-28 08:47:43 +00:00
|
|
|
Returns 0 if the caller was successfully requeued to the futex for
|
|
|
|
the futex word at
|
2015-01-14 12:35:52 +00:00
|
|
|
.IR uaddr2 .
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
2015-03-02 16:33:18 +00:00
|
|
|
No read access to the memory of a futex word.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B EAGAIN
|
2015-01-15 13:23:23 +00:00
|
|
|
.RB ( FUTEX_WAIT ,
|
2015-03-02 16:33:18 +00:00
|
|
|
.BR FUTEX_WAIT_BITSET ,
|
2015-01-15 13:23:23 +00:00
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI )
|
2015-01-14 16:16:58 +00:00
|
|
|
The value pointed to by
|
|
|
|
.I uaddr
|
|
|
|
was not equal to the expected value
|
|
|
|
.I val
|
|
|
|
at the time of the call.
|
2015-01-23 13:27:32 +00:00
|
|
|
|
|
|
|
.BR Note :
|
|
|
|
on Linux, the symbolic names
|
|
|
|
.B EAGAIN
|
|
|
|
and
|
|
|
|
.B EWOULDBLOCK
|
2015-02-04 20:40:49 +00:00
|
|
|
(both of which appear in different parts of the kernel futex code)
|
2015-01-23 13:27:32 +00:00
|
|
|
have the same value.
|
2015-01-14 16:16:58 +00:00
|
|
|
.TP
|
|
|
|
.B EAGAIN
|
2015-01-15 08:06:14 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
2015-01-15 07:30:16 +00:00
|
|
|
The value pointed to by
|
2012-08-13 12:25:13 +00:00
|
|
|
.I uaddr
|
|
|
|
is not equal to the expected value
|
|
|
|
.IR val3 .
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2015-01-14 09:41:20 +00:00
|
|
|
.BR EAGAIN
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-15 07:40:34 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
|
|
|
The futex owner thread ID of
|
|
|
|
.I uaddr
|
|
|
|
(for
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI :
|
|
|
|
.IR uaddr2 )
|
|
|
|
is about to exit,
|
2015-01-14 09:41:20 +00:00
|
|
|
but has not yet handled the internal state cleanup.
|
|
|
|
Try again.
|
|
|
|
.TP
|
2015-01-14 10:24:56 +00:00
|
|
|
.BR EDEADLK
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-23 13:27:32 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
The futex word at
|
2015-01-14 10:24:56 +00:00
|
|
|
.I uaddr
|
|
|
|
is already locked by the caller.
|
|
|
|
.TP
|
2015-01-15 09:15:34 +00:00
|
|
|
.BR EDEADLK
|
2015-08-07 20:41:53 +00:00
|
|
|
.\" FIXME . I see that kernel/locking/rtmutex.c uses EDEADLK in some
|
2015-07-27 11:31:38 +00:00
|
|
|
.\" places, and EDEADLOCK in others. On almost all architectures
|
2015-03-28 08:47:43 +00:00
|
|
|
.\" these constants are synonymous. Is there a reason that both
|
|
|
|
.\" names are used?
|
2015-07-30 08:19:44 +00:00
|
|
|
.\"
|
|
|
|
.\" tglx (July 2015): "No. We should probably fix that."
|
|
|
|
.\"
|
2015-01-15 09:15:34 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
While requeueing a waiter to the PI futex for the futex word at
|
2015-01-15 09:15:34 +00:00
|
|
|
.IR uaddr2 ,
|
|
|
|
the kernel detected a deadlock.
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B EFAULT
|
2014-06-04 06:54:43 +00:00
|
|
|
A required pointer argument (i.e.,
|
|
|
|
.IR uaddr ,
|
|
|
|
.IR uaddr2 ,
|
|
|
|
or
|
|
|
|
.IR timeout )
|
2014-06-04 07:39:08 +00:00
|
|
|
did not point to a valid user-space address.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2012-08-13 12:25:13 +00:00
|
|
|
.B EINTR
|
2012-08-13 12:50:26 +00:00
|
|
|
A
|
2012-08-13 12:25:13 +00:00
|
|
|
.B FUTEX_WAIT
|
2015-01-13 08:19:07 +00:00
|
|
|
or
|
|
|
|
.B FUTEX_WAIT_BITSET
|
2012-08-13 12:50:26 +00:00
|
|
|
operation was interrupted by a signal (see
|
futex Since Linux 2.6.22, EINTR can no longer occur on spurious wakeup
As reported by Rich Felker:
I see no code in the kernel whereby a "spurious wakeup",
or anything other than interruption by a signal handler
that's not SA_RESTART, can cause futex to fail with EINTR.
In general, overloading of EINTR and/or spurious EINTRs
from a syscall make it impossible to use that syscall for
implementing any function where EINTR is a mandatory
failure on interruption-by-signal, since there is no way
for userspace to distinguish whether the EINTR occurred
as a result of an interrupting signal or some other
reason. The kernel folks have gone to great lengths to fix
spurious EINTRs (see signal(7) for history), especially by
non-interrupting signal handlers, including in futex, and
allowing EINTR here would be contrary to that goal.
It's my belief that the "or a spurious wakeup" text should
simply be removed.
The reason I'm raising this topic is its relevance to a
thread on libc-alpha:
[RFC] mutex destruction (#13690): problem description and workarounds
The bug and mailing list discussions to which Rich refers are:
https://sourceware.org/bugzilla/show_bug.cgi?id=13690
https://sourceware.org/ml/libc-alpha/2014-12/threads.html#0001
Torvald Riegel also reported the same issue, and Thomas Gleixner
noted that the "EINTR on spurious wakeup" behavior went away in
Linux 2.6.22. See the LKML thread, "futex() man page update help
request", Jan 2015:
http://thread.gmane.org/gmane.linux.kernel/1703405/focus=7734
Reported-by: Rich Felker <dalias@libc.org>
Reported-by: Torvald Riegel <triegel@redhat.com>
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Michael Kerrisk <mtknpages@gmail.com>
2015-01-27 06:02:07 +00:00
|
|
|
.BR signal (7)).
|
|
|
|
In kernels before Linux 2.6.22, this error could also be returned for
|
|
|
|
on a spurious wakeup; since Linux 2.6.22, this no longer happens.
|
2012-08-13 12:25:13 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B EINVAL
|
2015-01-13 14:12:14 +00:00
|
|
|
The operation in
|
|
|
|
.IR futex_op
|
|
|
|
is one of those that employs a timeout, but the supplied
|
2014-06-04 06:57:48 +00:00
|
|
|
.I timeout
|
|
|
|
argument was invalid
|
|
|
|
.RI ( tv_sec
|
|
|
|
was less than zero, or
|
|
|
|
.IR tv_nsec
|
2015-07-27 10:59:18 +00:00
|
|
|
was not less than 1,000,000,000).
|
2014-06-04 06:57:48 +00:00
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-13 13:48:03 +00:00
|
|
|
The operation specified in
|
2015-01-15 09:19:43 +00:00
|
|
|
.IR futex_op
|
2015-01-13 13:48:03 +00:00
|
|
|
employs one or both of the pointers
|
2014-06-04 07:22:41 +00:00
|
|
|
.I uaddr
|
2014-06-04 08:25:57 +00:00
|
|
|
and
|
2015-01-13 13:48:03 +00:00
|
|
|
.IR uaddr2 ,
|
|
|
|
but one of these does not point to a valid object\(emthat is,
|
|
|
|
the address is not four-byte-aligned.
|
2014-06-04 07:22:41 +00:00
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-13 14:36:37 +00:00
|
|
|
.RB ( FUTEX_WAIT_BITSET ,
|
|
|
|
.BR FUTEX_WAKE_BITSET )
|
2015-12-19 05:10:00 +00:00
|
|
|
The bit mask supplied in
|
2015-01-13 14:34:17 +00:00
|
|
|
.IR val3
|
|
|
|
is zero.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-19 14:05:01 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
2014-06-04 08:16:52 +00:00
|
|
|
.I uaddr
|
|
|
|
equals
|
|
|
|
.IR uaddr2
|
|
|
|
(i.e., an attempt was made to requeue to the same futex).
|
|
|
|
.TP
|
2015-01-13 09:11:46 +00:00
|
|
|
.BR EINVAL
|
|
|
|
.RB ( FUTEX_FD )
|
|
|
|
The signal number supplied in
|
|
|
|
.I val
|
|
|
|
is invalid.
|
|
|
|
.TP
|
2015-01-12 14:38:13 +00:00
|
|
|
.B EINVAL
|
2015-01-15 09:18:31 +00:00
|
|
|
.RB ( FUTEX_WAKE ,
|
|
|
|
.BR FUTEX_WAKE_OP ,
|
|
|
|
.BR FUTEX_WAKE_BITSET ,
|
|
|
|
.BR FUTEX_REQUEUE ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE )
|
|
|
|
The kernel detected an inconsistency between the user-space state at
|
|
|
|
.I uaddr
|
|
|
|
and the kernel state\(emthat is, it detected a waiter which waits in
|
|
|
|
.BR FUTEX_LOCK_PI
|
|
|
|
on
|
|
|
|
.IR uaddr .
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-14 08:39:36 +00:00
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-14 11:27:42 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_UNLOCK_PI )
|
2015-01-14 08:39:36 +00:00
|
|
|
The kernel detected an inconsistency between the user-space state at
|
|
|
|
.I uaddr
|
|
|
|
and the kernel state.
|
2015-01-14 11:27:42 +00:00
|
|
|
This indicates either state corruption
|
|
|
|
or that the kernel found a waiter on
|
2015-01-14 08:39:36 +00:00
|
|
|
.I uaddr
|
|
|
|
which is waiting via
|
|
|
|
.BR FUTEX_WAIT
|
|
|
|
or
|
|
|
|
.BR FUTEX_WAIT_BITSET .
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-15 09:25:05 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
|
|
|
The kernel detected an inconsistency between the user-space state at
|
2015-01-15 09:29:30 +00:00
|
|
|
.I uaddr2
|
|
|
|
and the kernel state;
|
2015-10-08 10:17:59 +00:00
|
|
|
.\" From a conversation with Thomas Gleixner (Aug 2015): ###
|
|
|
|
.\" The kernel sees: I have non PI state for a futex you tried to
|
|
|
|
.\" tell me was PI
|
2015-01-15 09:29:30 +00:00
|
|
|
that is, the kernel detected a waiter which waits via
|
|
|
|
.BR FUTEX_WAIT
|
2015-07-30 08:19:44 +00:00
|
|
|
or
|
|
|
|
.BR FUTEX_WAIT_BITSET
|
2015-01-15 09:29:30 +00:00
|
|
|
on
|
|
|
|
.IR uaddr2 .
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
|
|
|
The kernel detected an inconsistency between the user-space state at
|
2015-01-15 09:25:05 +00:00
|
|
|
.I uaddr
|
|
|
|
and the kernel state;
|
|
|
|
that is, the kernel detected a waiter which waits via
|
2015-01-15 13:38:50 +00:00
|
|
|
.BR FUTEX_WAIT
|
2015-01-15 09:29:30 +00:00
|
|
|
or
|
2015-01-15 13:38:50 +00:00
|
|
|
.BR FUTEX_WAIT_BITESET
|
2015-01-15 09:25:05 +00:00
|
|
|
on
|
|
|
|
.IR uaddr .
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-15 09:29:30 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
2015-01-15 13:38:50 +00:00
|
|
|
The kernel detected an inconsistency between the user-space state at
|
|
|
|
.I uaddr
|
|
|
|
and the kernel state;
|
|
|
|
that is, the kernel detected a waiter which waits on
|
|
|
|
.I uaddr
|
|
|
|
via
|
|
|
|
.BR FUTEX_LOCK_PI
|
|
|
|
(instead of
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI ).
|
2015-01-15 09:29:30 +00:00
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-15 13:46:57 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
2015-07-30 08:19:44 +00:00
|
|
|
.\" This deals with the case:
|
|
|
|
.\" wait_requeue_pi(A, B);
|
|
|
|
.\" requeue_pi(A, C);
|
2015-01-15 13:46:57 +00:00
|
|
|
An attempt was made to requeue a waiter to a futex other than that
|
|
|
|
specified by the matching
|
|
|
|
.B FUTEX_WAIT_REQUEUE_PI
|
|
|
|
call for that waiter.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2015-01-15 13:53:20 +00:00
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
|
|
|
The
|
|
|
|
.I val
|
|
|
|
argument is not 1.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
2012-08-13 12:51:22 +00:00
|
|
|
Invalid argument.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2016-08-07 17:28:43 +00:00
|
|
|
.B ENFILE
|
|
|
|
.RB ( FUTEX_FD )
|
|
|
|
The system-wide limit on the total number of open files has been reached.
|
|
|
|
.TP
|
2015-01-14 08:13:03 +00:00
|
|
|
.BR ENOMEM
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-14 17:20:12 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
2015-01-14 08:13:03 +00:00
|
|
|
The kernel could not allocate memory to hold state information.
|
|
|
|
.TP
|
2008-01-31 10:35:05 +00:00
|
|
|
.B ENOSYS
|
|
|
|
Invalid operation specified in
|
2015-01-12 14:40:43 +00:00
|
|
|
.IR futex_op .
|
2012-08-13 12:25:13 +00:00
|
|
|
.TP
|
2015-01-12 11:52:28 +00:00
|
|
|
.B ENOSYS
|
|
|
|
The
|
|
|
|
.BR FUTEX_CLOCK_REALTIME
|
|
|
|
option was specified in
|
2015-01-13 13:53:51 +00:00
|
|
|
.IR futex_op ,
|
2015-01-12 11:52:28 +00:00
|
|
|
but the accompanying operation was neither
|
2016-06-23 08:29:41 +00:00
|
|
|
.BR FUTEX_WAIT ,
|
|
|
|
.BR FUTEX_WAIT_BITSET ,
|
2015-01-12 11:52:28 +00:00
|
|
|
nor
|
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI .
|
|
|
|
.TP
|
2015-01-14 11:06:21 +00:00
|
|
|
.BR ENOSYS
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-14 11:29:09 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
2015-01-15 08:16:53 +00:00
|
|
|
.BR FUTEX_UNLOCK_PI ,
|
2015-01-15 20:47:52 +00:00
|
|
|
.BR FUTEX_CMP_REQUEUE_PI ,
|
2015-01-15 08:17:54 +00:00
|
|
|
.BR FUTEX_WAIT_REQUEUE_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
A run-time check determined that the operation is not available.
|
2015-07-30 14:03:14 +00:00
|
|
|
The PI-futex operations are not implemented on all architectures and
|
2015-03-03 06:22:31 +00:00
|
|
|
are not supported on some CPU variants.
|
2015-01-14 11:06:21 +00:00
|
|
|
.TP
|
2015-01-14 08:43:31 +00:00
|
|
|
.BR EPERM
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-15 09:06:15 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
2015-01-15 09:04:31 +00:00
|
|
|
The caller is not allowed to attach itself to the futex at
|
2015-01-15 09:06:15 +00:00
|
|
|
.I uaddr
|
|
|
|
(for
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI :
|
|
|
|
the futex at
|
|
|
|
.IR uaddr2 ).
|
2015-01-14 08:43:31 +00:00
|
|
|
(This may be caused by a state corruption in user space.)
|
|
|
|
.TP
|
2015-01-14 11:31:44 +00:00
|
|
|
.BR EPERM
|
2015-01-15 07:31:06 +00:00
|
|
|
.RB ( FUTEX_UNLOCK_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
The caller does not own the lock represented by the futex word.
|
2015-01-14 11:31:44 +00:00
|
|
|
.TP
|
2015-01-14 09:19:25 +00:00
|
|
|
.BR ESRCH
|
|
|
|
.RB ( FUTEX_LOCK_PI ,
|
2015-01-23 13:27:32 +00:00
|
|
|
.BR FUTEX_TRYLOCK_PI ,
|
|
|
|
.BR FUTEX_CMP_REQUEUE_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
The thread ID in the futex word at
|
2015-01-14 09:19:25 +00:00
|
|
|
.I uaddr
|
|
|
|
does not exist.
|
|
|
|
.TP
|
2015-01-15 07:27:19 +00:00
|
|
|
.BR ESRCH
|
|
|
|
.RB ( FUTEX_CMP_REQUEUE_PI )
|
2015-03-02 16:33:18 +00:00
|
|
|
The thread ID in the futex word at
|
2015-01-15 07:27:19 +00:00
|
|
|
.I uaddr2
|
|
|
|
does not exist.
|
|
|
|
.TP
|
2012-08-13 12:25:13 +00:00
|
|
|
.B ETIMEDOUT
|
2015-01-13 13:52:53 +00:00
|
|
|
The operation in
|
|
|
|
.IR futex_op
|
|
|
|
employed the timeout specified in
|
|
|
|
.IR timeout ,
|
|
|
|
and the timeout expired before the operation completed.
|
2015-01-15 14:14:31 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH VERSIONS
|
2007-05-18 16:06:42 +00:00
|
|
|
.PP
|
2015-01-12 12:24:43 +00:00
|
|
|
Futexes were first made available in a stable kernel release
|
|
|
|
with Linux 2.6.0.
|
|
|
|
|
2015-03-28 08:47:43 +00:00
|
|
|
Initial futex support was merged in Linux 2.5.7 but with different
|
|
|
|
semantics from what was described above.
|
2015-01-13 14:14:12 +00:00
|
|
|
A four-argument system call with the semantics
|
2010-08-29 04:21:27 +00:00
|
|
|
described in this page was introduced in Linux 2.5.40.
|
2015-10-08 21:17:47 +00:00
|
|
|
A fifth argument was added in Linux 2.5.70,
|
|
|
|
and a sixth argument was added in Linux 2.6.7.
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH CONFORMING TO
|
2007-12-25 21:28:09 +00:00
|
|
|
This system call is Linux-specific.
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH NOTES
|
2015-01-15 20:36:26 +00:00
|
|
|
Glibc does not provide a wrapper for this system call; call it using
|
|
|
|
.BR syscall (2).
|
2015-07-27 11:09:45 +00:00
|
|
|
|
2015-07-28 06:52:47 +00:00
|
|
|
Several higher-level programming abstractions are implemented via futexes,
|
2015-12-29 12:51:32 +00:00
|
|
|
including POSIX semaphores and
|
2015-07-28 06:52:47 +00:00
|
|
|
various POSIX threads synchronization mechanisms
|
|
|
|
(mutexes, condition variables, read-write locks, and barriers).
|
2015-03-03 06:16:45 +00:00
|
|
|
.\" TODO FIXME(Torvald) Above, we cite this section and claim it contains
|
|
|
|
.\" details on the synchronization semantics; add the C11 equivalents
|
|
|
|
.\" here (or whatever we find consensus for).
|
2015-01-30 14:25:35 +00:00
|
|
|
.\"
|
|
|
|
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
.\"
|
|
|
|
.SH EXAMPLE
|
2015-12-19 05:21:41 +00:00
|
|
|
The program below demonstrates use of futexes in a program where a parent
|
|
|
|
process and a child process use a pair of futexes located inside a
|
2015-01-30 14:25:35 +00:00
|
|
|
shared anonymous mapping to synchronize access to a shared resource:
|
|
|
|
the terminal.
|
|
|
|
The two processes each write
|
|
|
|
.IR nloops
|
|
|
|
(a command-line argument that defaults to 5 if omitted)
|
|
|
|
messages to the terminal and employ a synchronization protocol
|
|
|
|
that ensures that they alternate in writing messages.
|
|
|
|
Upon running this program we see output such as the following:
|
|
|
|
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
$ \fB./futex_demo\fP
|
|
|
|
Parent (18534) 0
|
|
|
|
Child (18535) 0
|
|
|
|
Parent (18534) 1
|
|
|
|
Child (18535) 1
|
|
|
|
Parent (18534) 2
|
|
|
|
Child (18535) 2
|
|
|
|
Parent (18534) 3
|
|
|
|
Child (18535) 3
|
|
|
|
Parent (18534) 4
|
|
|
|
Child (18535) 4
|
|
|
|
.fi
|
|
|
|
.in
|
|
|
|
.SS Program source
|
|
|
|
\&
|
|
|
|
.nf
|
|
|
|
/* futex_demo.c
|
|
|
|
|
|
|
|
Usage: futex_demo [nloops]
|
|
|
|
(Default: 5)
|
|
|
|
|
|
|
|
Demonstrate the use of futexes in a program where parent and child
|
|
|
|
use a pair of futexes located inside a shared anonymous mapping to
|
|
|
|
synchronize access to a shared resource: the terminal. The two
|
|
|
|
processes each write \(aqnum\-loops\(aq messages to the terminal and employ
|
|
|
|
a synchronization protocol that ensures that they alternate in
|
|
|
|
writing messages.
|
|
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <linux/futex.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int *futex1, *futex2, *iaddr;
|
|
|
|
|
|
|
|
static int
|
|
|
|
futex(int *uaddr, int futex_op, int val,
|
|
|
|
const struct timespec *timeout, int *uaddr2, int val3)
|
|
|
|
{
|
|
|
|
return syscall(SYS_futex, uaddr, futex_op, val,
|
|
|
|
timeout, uaddr, val3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Acquire the futex pointed to by \(aqfutexp\(aq: wait for its value to
|
|
|
|
become 1, and then set the value to 0. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fwait(int *futexp)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* __sync_bool_compare_and_swap(ptr, oldval, newval) is a gcc
|
|
|
|
built\-in function. It atomically performs the equivalent of:
|
|
|
|
|
|
|
|
if (*ptr == oldval)
|
|
|
|
*ptr = newval;
|
|
|
|
|
|
|
|
It returns true if the test yielded true and *ptr was updated.
|
|
|
|
The alternative here would be to employ the equivalent atomic
|
|
|
|
machine\-language instructions. For further information, see
|
|
|
|
the GCC Manual. */
|
|
|
|
|
|
|
|
while (1) {
|
2015-03-03 08:05:30 +00:00
|
|
|
|
2015-02-28 01:25:47 +00:00
|
|
|
/* Is the futex available? */
|
2015-03-03 08:05:30 +00:00
|
|
|
|
2015-01-30 14:25:35 +00:00
|
|
|
if (__sync_bool_compare_and_swap(futexp, 1, 0))
|
|
|
|
break; /* Yes */
|
|
|
|
|
2015-02-28 01:25:47 +00:00
|
|
|
/* Futex is not available; wait */
|
2015-03-03 08:05:30 +00:00
|
|
|
|
2015-02-28 01:25:47 +00:00
|
|
|
s = futex(futexp, FUTEX_WAIT, 0, NULL, NULL, 0);
|
|
|
|
if (s == \-1 && errno != EAGAIN)
|
|
|
|
errExit("futex\-FUTEX_WAIT");
|
2015-01-30 14:25:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release the futex pointed to by \(aqfutexp\(aq: if the futex currently
|
|
|
|
has the value 0, set its value to 1 and the wake any futex waiters,
|
|
|
|
so that if the peer is blocked in fpost(), it can proceed. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
fpost(int *futexp)
|
|
|
|
{
|
|
|
|
int s;
|
|
|
|
|
|
|
|
/* __sync_bool_compare_and_swap() was described in comments above */
|
|
|
|
|
|
|
|
if (__sync_bool_compare_and_swap(futexp, 0, 1)) {
|
|
|
|
|
|
|
|
s = futex(futexp, FUTEX_WAKE, 1, NULL, NULL, 0);
|
|
|
|
if (s == \-1)
|
|
|
|
errExit("futex\-FUTEX_WAKE");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
pid_t childPid;
|
|
|
|
int j, nloops;
|
|
|
|
|
|
|
|
setbuf(stdout, NULL);
|
|
|
|
|
|
|
|
nloops = (argc > 1) ? atoi(argv[1]) : 5;
|
|
|
|
|
|
|
|
/* Create a shared anonymous mapping that will hold the futexes.
|
|
|
|
Since the futexes are being shared between processes, we
|
|
|
|
subsequently use the "shared" futex operations (i.e., not the
|
|
|
|
ones suffixed "_PRIVATE") */
|
|
|
|
|
|
|
|
iaddr = mmap(NULL, sizeof(int) * 2, PROT_READ | PROT_WRITE,
|
|
|
|
MAP_ANONYMOUS | MAP_SHARED, \-1, 0);
|
|
|
|
if (iaddr == MAP_FAILED)
|
|
|
|
errExit("mmap");
|
|
|
|
|
|
|
|
futex1 = &iaddr[0];
|
|
|
|
futex2 = &iaddr[1];
|
|
|
|
|
|
|
|
*futex1 = 0; /* State: unavailable */
|
|
|
|
*futex2 = 1; /* State: available */
|
|
|
|
|
|
|
|
/* Create a child process that inherits the shared anonymous
|
2015-03-03 06:22:56 +00:00
|
|
|
mapping */
|
2015-01-30 14:25:35 +00:00
|
|
|
|
|
|
|
childPid = fork();
|
2015-03-03 07:19:47 +00:00
|
|
|
if (childPid == \-1)
|
2015-01-30 14:25:35 +00:00
|
|
|
errExit("fork");
|
|
|
|
|
|
|
|
if (childPid == 0) { /* Child */
|
|
|
|
for (j = 0; j < nloops; j++) {
|
|
|
|
fwait(futex1);
|
|
|
|
printf("Child (%ld) %d\\n", (long) getpid(), j);
|
|
|
|
fpost(futex2);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parent falls through to here */
|
|
|
|
|
|
|
|
for (j = 0; j < nloops; j++) {
|
|
|
|
fwait(futex2);
|
|
|
|
printf("Parent (%ld) %d\\n", (long) getpid(), j);
|
|
|
|
fpost(futex1);
|
|
|
|
}
|
|
|
|
|
|
|
|
wait(NULL);
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
.fi
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH SEE ALSO
|
2015-01-15 20:16:27 +00:00
|
|
|
.ad l
|
2015-01-13 16:03:14 +00:00
|
|
|
.BR get_robust_list (2),
|
2013-07-30 03:09:22 +00:00
|
|
|
.BR restart_syscall (2),
|
2015-07-28 06:38:43 +00:00
|
|
|
.BR pthread_mutexattr_getprotocol (3),
|
2015-07-30 13:43:54 +00:00
|
|
|
.BR futex (7),
|
|
|
|
.BR sched (7)
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2015-01-14 14:20:59 +00:00
|
|
|
The following kernel source files:
|
|
|
|
.IP * 2
|
|
|
|
.I Documentation/pi-futex.txt
|
|
|
|
.IP *
|
|
|
|
.I Documentation/futex-requeue-pi.txt
|
|
|
|
.IP *
|
|
|
|
.I Documentation/locking/rt-mutex.txt
|
|
|
|
.IP *
|
|
|
|
.I Documentation/locking/rt-mutex-design.txt
|
2015-01-16 14:58:08 +00:00
|
|
|
.IP *
|
|
|
|
.I Documentation/robust-futex-ABI.txt
|
2015-01-13 21:19:31 +00:00
|
|
|
.PP
|
2015-01-15 20:16:27 +00:00
|
|
|
Franke, H., Russell, R., and Kirwood, M., 2002.
|
2007-06-21 21:58:51 +00:00
|
|
|
\fIFuss, Futexes and Furwocks: Fast Userlevel Locking in Linux\fP
|
2015-01-15 20:16:27 +00:00
|
|
|
(from proceedings of the Ottawa Linux Symposium 2002),
|
2010-05-22 03:23:14 +00:00
|
|
|
.br
|
capget.2, futex.2, sched_setscheduler.2, spu_create.2, spu_run.2, vfork.2, getnameinfo.3, netlink.3, cciss.4, console_codes.4, dsp56k.4, hpsa.4, sk98lin.4, filesystems.5, protocols.5, aio.7, capabilities.7, charsets.7, feature_test_macros.7, futex.7, hier.7, iso_8859-16.7, iso_8859-2.7, koi8-r.7, libc.7, man.7, netlink.7, numa.7, standards.7, unicode.7, units.7, uri.7, x25.7: Global fix: use UR macro where applicable
The syntax .UR http://example.com paired with .UE will create
links which one can interact, if the pager allows that. One
way to see the effect is ask the man(1) command to use browser
display, e.g.:
man -H man7/uri.7
("\:" is optional groff syntax to permit hyphenless line breaks.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-08-13 08:02:36 +00:00
|
|
|
.UR http://kernel.org\:/doc\:/ols\:/2002\:/ols2002-pages-479-495.pdf
|
|
|
|
.UE
|
2015-01-12 16:00:14 +00:00
|
|
|
|
2015-01-15 20:16:27 +00:00
|
|
|
Hart, D., 2009. \fIA futex overview and update\fP,
|
2015-01-15 05:51:05 +00:00
|
|
|
.UR http://lwn.net/Articles/360699/
|
|
|
|
.UE
|
|
|
|
|
2015-01-15 20:16:27 +00:00
|
|
|
Hart, D. and Guniguntala, D., 2009.
|
2015-01-14 14:19:51 +00:00
|
|
|
\fIRequeue-PI: Making Glibc Condvars PI-Aware\fP
|
2015-01-15 20:16:27 +00:00
|
|
|
(from proceedings of the 2009 Real-Time Linux Workshop),
|
2015-01-14 14:19:51 +00:00
|
|
|
.UR http://lwn.net/images/conf/rtlws11/papers/proc/p10.pdf
|
|
|
|
.UE
|
|
|
|
|
2015-01-15 20:16:27 +00:00
|
|
|
Drepper, U., 2011. \fIFutexes Are Tricky\fP,
|
2015-01-12 16:00:14 +00:00
|
|
|
.UR http://www.akkadia.org/drepper/futex.pdf
|
|
|
|
.UE
|
2010-05-22 03:23:14 +00:00
|
|
|
.PP
|
|
|
|
Futex example library, futex-*.tar.bz2 at
|
|
|
|
.br
|
2013-09-30 18:50:43 +00:00
|
|
|
.UR ftp://ftp.kernel.org\:/pub\:/linux\:/kernel\:/people\:/rusty/
|
capget.2, futex.2, sched_setscheduler.2, spu_create.2, spu_run.2, vfork.2, getnameinfo.3, netlink.3, cciss.4, console_codes.4, dsp56k.4, hpsa.4, sk98lin.4, filesystems.5, protocols.5, aio.7, capabilities.7, charsets.7, feature_test_macros.7, futex.7, hier.7, iso_8859-16.7, iso_8859-2.7, koi8-r.7, libc.7, man.7, netlink.7, numa.7, standards.7, unicode.7, units.7, uri.7, x25.7: Global fix: use UR macro where applicable
The syntax .UR http://example.com paired with .UE will create
links which one can interact, if the pager allows that. One
way to see the effect is ask the man(1) command to use browser
display, e.g.:
man -H man7/uri.7
("\:" is optional groff syntax to permit hyphenless line breaks.)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-08-13 08:02:36 +00:00
|
|
|
.UE
|
2015-01-14 11:16:42 +00:00
|
|
|
.\"
|
2015-03-03 06:16:45 +00:00
|
|
|
.\" FIXME(Torvald) We should probably refer to the glibc code here, in
|
2016-10-29 10:03:12 +00:00
|
|
|
.\" particular the glibc-internal futex wrapper functions that are
|
|
|
|
.\" WIP, and the generic pthread_mutex_t and perhaps condvar
|
|
|
|
.\" implementations.
|