Skip to content

Instantly share code, notes, and snippets.

@kangaroo
Created June 17, 2010 05:20
Show Gist options
  • Save kangaroo/441716 to your computer and use it in GitHub Desktop.
Save kangaroo/441716 to your computer and use it in GitHub Desktop.
typedef struct _pthread
{
long sig; /* Unique signature for this structure */
struct __darwin_pthread_handler_rec *__cleanup_stack;
pthread_lock_t lock; /* Used for internal mutex on structure */
uint32_t detached:8,
inherit:8,
policy:8,
freeStackOnExit:1,
newstyle:1,
kernalloc:1,
schedset:1,
wqthread:1,
wqkillset:1,
pad:2;
size_t guardsize; /* size in bytes to guard stack overflow */
#if !defined(__LP64__)
int pad0; /* for backwards compatibility */
#endif
struct sched_param param;
struct _pthread_mutex *mutexes;
struct _pthread *joiner;
#if !defined(__LP64__)
int pad1; /* for backwards compatibility */
#endif
void *exit_value;
semaphore_t death; /* pthread_join() uses this to wait for death's call */
mach_port_t kernel_thread; /* kernel thread this thread is bound to */
void *(*fun)(void*);/* Thread start routine */
void *arg; /* Argment for thread start routine */
int cancel_state; /* Whether thread can be cancelled */
int err_no; /* thread-local errno */
void *tsd[_EXTERNAL_POSIX_THREAD_KEYS_MAX + _INTERNAL_POSIX_THREAD_KEYS_MAX]; /* Thread specific data */
void *stackaddr; /* Base of the stack (is aligned on vm_page_size boundary */
size_t stacksize; /* Size of the stack (is a multiple of vm_page_size and >= PTHREAD_STACK_MIN) */
mach_port_t reply_port; /* Cached MiG reply port */
#if defined(__LP64__)
int pad2; /* for natural alignment */
#endif
void *cthread_self; /* cthread_self() if somebody calls cthread_set_self() */
/* protected by list lock */
uint32_t childrun:1,
parentcheck:1,
childexit:1,
pad3:29;
#if defined(__LP64__)
int pad4; /* for natural alignment */
#endif
TAILQ_ENTRY(_pthread) plist;
void * freeaddr;
size_t freesize;
mach_port_t joiner_notify;
char pthread_name[MAXTHREADNAMESIZE]; /* including nulll the name */
int max_tsd_key;
void * cur_workq;
void * cur_workitem;
uint64_t thread_id;
} *pthread_t;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment