Skip to content

Glossary

Workqueue (pthread workqueue)

The kernel-managed thread pool that backs libdispatch and direct pthread_workqueue clients. Threads bucketed by QoS, created and destroyed dynamically.

The workqueue — sometimes spelled pthread_workqueue — is the kernel-managed thread pool that runs blocks submitted to libdispatch queues. One pool per process, with separate buckets per QoS class.

What the kernel manages:

  • Spawning workers on demand when a queue has work and no idle worker exists.
  • Killing workers when sustained demand drops.
  • Bucketing by QoS — workers belong to one QoS bucket; the bucket determines scheduling priority.
  • Capping concurrency — based on CPU count, system load, and memory pressure.

apple-oss-distributions/xnubsd/kern/pthread_shims.cThe kernel side of the workqueue — thread allocation and QoS integration.View on GitHub(line ) apple-oss-distributions/libpthreadsrc/qos.cThe userspace side that requests workqueue threads from the kernel.View on GitHub(line )

The pool is shared across libdispatch and direct pthread_workqueue clients. Apps don't usually use it directly; libdispatch is the canonical interface.

Submitting 10K blocks to a concurrent queue does not spawn 10K threads — the pool throttles based on hardware (typically one worker per logical CPU per QoS, plus a small overhead) and dynamically grows/shrinks.

See also: dispatch queue, QoS class, and the libdispatch internals article.