Search code examples
constantsglibc

Where does the aio_threads defined in glibc?


// file: glibc/rt/aio_misc.c

/* User optimization.  */
void
__aio_init (const struct aioinit *init)
{
  /* Get the mutex.  */
  __pthread_mutex_lock (&__aio_requests_mutex);
  /* Only allow writing new values if the table is not yet allocated.  */
  if (pool == NULL)
    {
      optim.aio_threads = init->aio_threads < 1 ? 1 : init->aio_threads;
      assert (powerof2 (ENTRIES_PER_ROW));
      optim.aio_num = (init->aio_num < ENTRIES_PER_ROW
               ? ENTRIES_PER_ROW
               : init->aio_num & ~(ENTRIES_PER_ROW - 1));
    }
  if (init->aio_idle_time != 0)
    optim.aio_idle_time = init->aio_idle_time;
  /* Release the mutex.  */
  __pthread_mutex_unlock (&__aio_requests_mutex);
}

aio_threads This field specifies the maximum number of worker threads that may be used by the implementation. If the number of outstanding I/O operations exceeds this limit, then excess operations will be queued until a worker thread becomes free. If this field is specified with a value less than 1, the value 1 is used.
The default value is 20.

Then I am confused to find where aio_threads is defined in the glibc source code, but found nothing there. The argument in __aio_init() is a const struct aioinit *, I think some const struct aioinit object must be defined. But I failed.


Solution

  • It is a member of the data structure here called optim