4

When investigating some performance issues, I finally ended up in gthread-posix.c. There I found code such as:

static void __attribute__((noinline))
g_mutex_lock_slowpath (GMutex *mutex)
{
  /* Set to 2 to indicate contention.  If it was zero before then we
   * just acquired the lock.
   *
   * Otherwise, sleep for as long as the 2 remains...
   */
  while (exchange_acquire (&mutex->i[0], 2) != 0)
    syscall (__NR_futex, &mutex->i[0], (gsize) FUTEX_WAIT, (gsize) 2, NULL);
}

I am curious as to why it doesn't use FUTEX_WAIT_PRIVATE here and it other places. At least on the ARM the non-private futexes are significantly slower, and I was under the impression that glib is for multithreading rather than interprocess communication in shared memory.

1 Answers1

0

GLib does now use FUTEX_WAIT_PRIVATE, since March 2015. See this commit and the related bug report.

Philip Withnall
  • 5,293
  • 14
  • 28