Questions tagged [futex]

"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

https://en.wikipedia.org/wiki/Futex

107 questions
2
votes
2 answers

Python hangs in futex calls

I have a Python daemon running in production. It employs between 7 and 120 threads. Recently the smallest instance (7 threads) started to show hangs while all other instances never showed this kind of problem. Attaching strace to the python process…
Helmut Grohne
  • 6,578
  • 2
  • 31
  • 67
2
votes
2 answers

Find threading.Lock's futex id

I want to instrument a large Python project to be able to debug production issues that look like this: 23321 07:49:57.925037 futex(0x23b2c20, FUTEX_WAIT_PRIVATE, 0, NULL 23321 07:50:12.435793 <... futex resumed> ) = 0 Here, a…
Dima Tisnek
  • 11,241
  • 4
  • 68
  • 120
2
votes
1 answer

messed up using do_futex?

I'm getting a weird error. I implemented these two functions: int flag_and_sleep(volatile unsigned int *flag) { int res = 0; (*flag) = 1; res = syscall(__NR_futex, flag, FUTEX_WAIT, 1, NULL, NULL, 0); if(0 == res && (0 !=…
n-alexander
  • 14,663
  • 12
  • 42
  • 43
2
votes
2 answers

boost - timed_wait does not wait

I am running the following code on a Linux OS + ARM processor + boost 1.51. But, the code does not work as intended and the timed_wait() call returns immediately. #include #include #include…
Bob
  • 31
  • 4
2
votes
0 answers

why glibc futex hang up

I have write a program using err_doit function referred in APUE. This program will use this function print amount of message in a endless loop. But it always hangs up when running a couple of minutes later. I use strace command attached this process…
lisency
  • 433
  • 1
  • 5
  • 9
2
votes
1 answer

Can I mix futex-based mutexes with glibc-2.2 linuxthreads mutexes?

If you don't know what is futex and linuxthreads-0.9, please, don't reply. Can I mix in one program futex-based mutex with mutex from linuxthreads-0.8 or -0.9 (which was used in all glibc <=2.2 and in all uClibc) ? I need interprocess mutex (pshared…
osgx
  • 90,338
  • 53
  • 357
  • 513
2
votes
1 answer

How come a futex take longer than a mutex on waking a thread?

I was trying to measure the latency when a thread calling to wake up a sleeping thread. Since it has been said that many synchronization premitives are developed on top of futex, I am expecting futex are always faster. However, my test was giving…
Codeblue
  • 31
  • 3
2
votes
1 answer

Berkeley DB: stuck at futex_wait because of previous abnormal quit during c api call

I'm programming in C, using berkeley db 4.3 (/usr/lib64/libdb-4.3.so) on RHEL5.6 with kernel 2.6.18-238_xen_AMD64. In my tests (writing 1,000,000 key/value pairs), if one process quitted abnormally (ctrl + c, kill, or assert fails) while an…
felix021
  • 1,936
  • 3
  • 16
  • 20
2
votes
0 answers

Command executed through popen() hangs randomly

My program has this weird problem: It tries to find a device by reading the output of some commands through a pipe: FILE* fp = NULL; fp = popen ("cd /sys/bus/usb/devices; grep -i NDI */product", "r"); and then uses fgets() to read the file stream…
Jim
  • 21
  • 5
2
votes
2 answers

Can strace prevent the proper execution of a program?

I would like to know whether strace can cause anomaly for the program it is tracing. Currently, I am trying to trace a random segmentation fault error (but it seems like the program never crashes that way when I use strace) which is caused in a line…
xQuare
  • 1,293
  • 1
  • 12
  • 21
1
vote
3 answers

Linux 3.0: futex-lock deadlock bug?

// SubFetch(x,y) = atomically x-=y and return x (__sync_sub_and_fetch) // AddFetch(x,y) = atomically x+=y and return x (__sync_add_and_fetch) // CompareWait(x, y) = futex(&x, FUTEX_WAIT, y) wait on x if x == y // Wake(x, y) = futex(&x, FUTEX_WAKE,…
Andrew Tomazos
  • 66,139
  • 40
  • 186
  • 319
1
vote
2 answers

How would I implement this method using a futex?

This method (I realize the function might need some extra parameters): void waitUntilNotEqual(volatile int* addr, int value) { while (*addr == value) {} }
Chris
  • 6,642
  • 7
  • 42
  • 55
1
vote
0 answers

Futex Syscall in C Always Returns errno 14

Every time I try to make a futex-related system call in C, I get a return value of -1 and errno = 14 (EFAULT - Bad Address). First I adapted code from the futex manpage. Futex Manpage My changes are small and are as follows: Print futexes …
Jacob Quisenberry
  • 1,131
  • 3
  • 20
  • 48
1
vote
1 answer

How one pthread waits for another to finish via futex in linux?

I want to create thread via linux clone() and and wait for it to finish. Such a seemingly simple case has become difficult for me because I don’t know how to wait in the calling thread for the end of the called. Linux wait() does not work for…
xperious
  • 239
  • 3
  • 10
1
vote
1 answer

Futex and pthreads issue

I'm testing futexes with pthreads. I've written following program: #include #include #include #include #include #include #include #include #include…
user2699113
  • 4,262
  • 3
  • 25
  • 43