in src/introspection.c [54:88]
static void _dispatch_introspection_queue_order_dispose(
dispatch_queue_introspection_context_t dqic);
#pragma mark -
#pragma mark dispatch_introspection_init
void
_dispatch_introspection_init(void)
{
_dispatch_introspection.debug_queue_inversions =
_dispatch_getenv_bool("LIBDISPATCH_DEBUG_QUEUE_INVERSIONS", false);
// Hack to determine queue TSD offset from start of pthread structure
uintptr_t thread = _dispatch_thread_self();
thread_identifier_info_data_t tiid;
mach_msg_type_number_t cnt = THREAD_IDENTIFIER_INFO_COUNT;
kern_return_t kr = thread_info(pthread_mach_thread_np((void*)thread),
THREAD_IDENTIFIER_INFO, (thread_info_t)&tiid, &cnt);
if (!dispatch_assume_zero(kr)) {
_dispatch_introspection.thread_queue_offset =
(void*)(uintptr_t)tiid.dispatch_qaddr - (void*)thread;
}
_dispatch_thread_key_create(&dispatch_introspection_key,
_dispatch_introspection_thread_remove);
_dispatch_introspection_thread_add(); // add main thread
for (size_t i = 0; i < DISPATCH_ROOT_QUEUE_COUNT; i++) {
_dispatch_trace_queue_create(&_dispatch_root_queues[i]);
}
#if DISPATCH_USE_MGR_THREAD && DISPATCH_USE_PTHREAD_ROOT_QUEUES
_dispatch_trace_queue_create(_dispatch_mgr_q.do_targetq);
#endif
_dispatch_trace_queue_create(&_dispatch_main_q);
_dispatch_trace_queue_create(&_dispatch_mgr_q);
}