"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
1
vote
1 answer
Is it safe to cast atomic to T
I have two questions:
In the general case is it safe to use an atomic as a T and switch between them interchangeably?
In the case of a futex is it safe to do the cast?
I am aware that performing atomic operations on non-atomic types is undefined…

Ebony Ayers
- 350
- 1
- 3
- 9
1
vote
2 answers
Intel-64 and ia32 atomic operations acquire-release semantics and GCC 5+
I am investigating Intel CPU atomic features on my Haswell CPU
(a 4/8 core 2.3-3.9ghz i7-4790M), and am finding it really hard
to construct eg. reliable mutex_lock() and mutex_unlock()
operations as suggested by for instance the GCC manual:
6.53…

JVD
- 645
- 1
- 7
- 17
1
vote
2 answers
How could futex_wake return 0
I implemented semaphore using futex. The following program often fails at the assertion in sem_post(). While the return value is supposed to be 1, it sometimes returns 0. How can this happen?
When I use POSIX semaphore the program always finishes…

zhao
- 232
- 3
- 15
1
vote
1 answer
pthread_mutex_lock and EAGAIN
I've use pthread for multithreded program and I've got the following situation.
When I run the code without sleep command it causes error at run time, and when I add the sleep command program runs as expected.
With sleep:
#include…

Matan
- 43
- 6
1
vote
3 answers
Small OpenMP program sometimes freezes (gcc, c, linux)
Just write a small omp test, and it does not work correctly all the times:
#include
int main() {
int i,j=0;
#pragma omp parallel
for(i=0;i<1000;i++)
{
#pragma omp barrier
j+= j^i;
}
return j;
}
The usage of j for writing from…

osgx
- 90,338
- 53
- 357
- 513
1
vote
0 answers
Parallel (OpenMP) Fortran code stalls after long time without giving error
Running a Fortran code containing a parallel OpenMP region, I have encountered a problem that after the code runs fine for some time (counter=~1,000,000,000 in the code below), it stalls without crashing or providing any errors. A code snippet…

Ziegl
- 147
- 9
1
vote
1 answer
Too many futex() calls
We are observing unusual delays in one of our Java apps on a Linux RedHat machine while trying to publish to an external MQ queue (It never happened before). Did a quick health check on the box and the CPU/memory usage seems quite alright. The MQ…

joesatch
- 137
- 1
- 1
- 12
1
vote
1 answer
Why a java single threaded program uses futex and clone system calls
This is a single threaded java program to find factorial of a given number passed as an argument, using recursion.
class factorial{
public static void main(String[] args){
int number=0;
try {
number = Integer.parseInt(args[0]);
…

nohup
- 3,105
- 3
- 27
- 52
1
vote
0 answers
CentOS: spin lock consuming high CPU while running a multi-threaded application
I'm running a multi-threaded application written in C++ on a Cent-OS machine. The "top" command output is showing that the application is eating most of the CPU and it's eating as system CPU (not user CPU). Then I thought of running "perf top"…

nik_kgp
- 1,112
- 1
- 9
- 17
1
vote
0 answers
implement mutex supporting 32-bit app and 64-bit apps at the same time
As we know, in the libpthread on Linux the mutex has different size in 32-bit mode and 64-bit mode. It is not possible to share a mutex in shared-memory between 32-bit apps and 64-bit apps running on the same Linux box. (If i was wrong about this,…

user1783732
- 1,599
- 5
- 22
- 44
1
vote
1 answer
What is the most efficient way to manage tracking waiters with futex-based locks?
I've been using a waiter-count approach to futex-based locks: adjacent to the futex int, having a second int that's a waiter count which waiters contending for the lock atomically increment before performing a futex wait operation, and atomically…

R.. GitHub STOP HELPING ICE
- 208,859
- 35
- 376
- 711
1
vote
1 answer
How futex works in this case?
I have a sample code of futex.
But i couldnt understand the code flow....
#include
#include
#include
#include
#include
#define NUM 50
int futex_addr;
int futex_wait(void* addr, int…

Prashanth Cm
- 151
- 2
- 4
- 8
1
vote
1 answer
WSO2 API Manager: Suse kernel parameters
Are there any recommendations/requirements on WSO2 API Manager related tokernel parameters on Suse 64bit? Such as no-files, semaphores, etc?

Marc
- 524
- 5
- 19
1
vote
0 answers
Interpreting tcmalloc's MALLOCSTATS output
I am trying to fix performance problem with a multi threaded application which uses tcmalloc. Each threads creates large number of objects and my analysis is that thread caches in tcmalloc are not able to allocate memory and often tries to fetch…

Jithin
- 1,108
- 2
- 12
- 26
1
vote
1 answer
how to check if pthread_mutex is based on robust futex
I am trying to use robust futex based pthread mutex in Linux because I need to be both fast and robust (recover the "dead" lock). How can I check if the pthread mutex library on any Linux system is based off robust futex?
Thanks!

user1783732
- 1,599
- 5
- 22
- 44