"A futex (short for “fast userspace mutex”) is a kernel system call that programmers can use to implement basic locking, or as a building block for higher-level locking abstractions such as semaphores and POSIX mutexes or condition variables." -- From Wikipedia
Questions tagged [futex]
107 questions
3
votes
1 answer
futex-based 4-byte single-writer/multiple-readers lock
Looking for a minimal, futex-based implementation of a single-writer/multiple-readers lock requiring no space overhead beyond a single 4-byte futex state variable.
Some background: I have an application which will embed a lock within each of tens to…

John Yates
- 1,027
- 1
- 7
- 18
3
votes
3 answers
Futex based locking mechanism
Somebody can tell me an example of using locking mechanism based on futex? (for muticore x86 CPU, CentOS)

Dima
- 1,253
- 3
- 21
- 31
3
votes
1 answer
Causing a waiting thread to return to userspace
Would it be possible to wake up a thread that is waiting on a futex lock? I tried
using a signal mechanism but it does not seem to work. Are there any other approches
I could try out? Below, I've added in an example that might be similar to what…
user277465
3
votes
1 answer
iOS futex support
Is there any way to implement a fast spinlock on iOS that reverts to blocking on an OS primitive if and only if there's contention? I'm looking for something equivalent to these implementations:
http://locklessinc.com/articles/keyed_events/ (Fast…

Falcon
- 445
- 3
- 10
3
votes
1 answer
How can I debug this User Space application crash?
I'm running a Qt5.4.0 application on my embedded Linux system (TI AM335x based) and it's stopping to run and I'm having a hard time debugging this. This is a QtWebKit QML example (youtubeview) but other QtWebKit examples are preforming the same for…

Mike
- 47,263
- 29
- 113
- 177
3
votes
0 answers
Android does not support robust futexes, so how to implement a robust mutex?
I found the pthread.h in android ndk does not include robust futexes functions, so what should I do if I want to access a shared memory(mmap) between multiple processes?
PS: Now, I use std::shared_mutex + fcntl, which the shared_mutex is for thread,…

alpha
- 1,228
- 1
- 11
- 26
3
votes
2 answers
Linux futex for 64-bits
I am on a 64-bit Linux box:
Linux illin793 2.6.32-279.5.2.el6.x86_64 #1 SMP Tue Aug 14 11:36:39
EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
From man futex:
int futex(int *uaddr, int op, int val, const struct timespec *timeout,
int *uaddr2, int…

Alex
- 133
- 1
- 10
3
votes
1 answer
why sem_t is 32 bytes in 64bit linux?
sem_t in 64bit linux is 32 bytes, but with futex implementation, 8bytes is enough(glibc sem_post), is it true? if it is true, why make it wasting bytes?
Actually I want to use a custom semaphore implementation which use only 8bytes, thus using one…

user1733712
- 105
- 1
- 5
3
votes
1 answer
C - Program freezes; futex_wait_queue_me
I have, as requested, included the code in its entirety so that you can test it. Keep in mind that this is nowhere near completion, but should be able to send and recieve packets through a stable tcp connection.
When I run it I get:
./bunny -i…

youjustreadthis
- 622
- 3
- 9
- 24
2
votes
0 answers
mutex and condition variable implementation using futex
I have implemented mutex and contition variables using futex syscall. I believe that my implementation is correct, but would like it to be verified by some one else. If some of you could verify its correctness, it would be a great help.
Any…

Sudhanshu
- 51
- 6
2
votes
0 answers
Perl threads sometimes get stuck (some of them waiting for futex)
I'm facing a problem with a multi-threaded Perl application that I'm trying to run (on Redhat 7.4 using Perl 5.10.1). The problem has been reproduced through the setup below (setup is similar to the original Perl application):
There are 2 files:…

rick7morty
- 31
- 3
2
votes
0 answers
Rocket App hangs on linux while waiting for futex
I have a simple rocket 0.5.0-dev app
main.rs
#[macro_use] extern crate rocket;
use rocket::http::{Status};
use rocket::State;
use std::sync::{Mutex, Arc};
struct Event {}
#[get("/health")]
fn health() -> Result<&'static str, Status> {
…

Yasammez
- 1,383
- 12
- 15
2
votes
0 answers
Futex design and backoff
I am writing something without libc and I need a mutex for synchronization (I used #![cfg_attr(not(test), no_std)]). Here is my code:
const FREE: u8 = 0;
const LOCKED: u8 = 1;
const FUTEX_MODE: u8 = 2;
const BACKOFF_LIMIT: usize =…

Schrodinger ZHU
- 169
- 6
2
votes
2 answers
How to find what causes the futex facility to fail?
I am trying to synchronize 5 processes, they have to be created from the same father.
I tried inserting 5 waitpids to wait for the child process to end, but the code never reaches D4 and D5.
#include
#include
#include…

AQUATH
- 33
- 2
- 12
2
votes
2 answers
Is there a way to call library thread-local init/cleanup on thread creation/destruction?
This question is similar to How to call a function on a thread's creation and exit? but more specific. In another multi-process shared memory project I used a combination of an __attribute__((constructor)) labeled library init routine, lazy…

Whilom Chime
- 366
- 1
- 9