X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..99c3a10404e5d1ef94397ab4df5a8b74711fc4d3:/bsd/sys/pthread_internal.h diff --git a/bsd/sys/pthread_internal.h b/bsd/sys/pthread_internal.h index dc68c04c2..b22de04d8 100644 --- a/bsd/sys/pthread_internal.h +++ b/bsd/sys/pthread_internal.h @@ -29,12 +29,32 @@ #ifndef _SYS_PTHREAD_INTERNAL_H_ #define _SYS_PTHREAD_INTERNAL_H_ -#undef pthread_mutexattr_t; - +#include #include -#define WORKITEM_SIZE 64 -#define WORKQUEUE_NUMPRIOS 3 +struct ksyn_waitq_element { + TAILQ_ENTRY(ksyn_waitq_element) kwe_list; /* link to other list members */ + void * kwe_kwqqueue; /* queue blocked on */ + uint32_t kwe_flags; /* flags */ + uint32_t kwe_lockseq; /* the sequence of the entry */ + uint32_t kwe_count; /* upper bound on number of matches still pending */ + uint32_t kwe_psynchretval; /* thread retval */ + void *kwe_uth; /* uthread */ +}; +typedef struct ksyn_waitq_element * ksyn_waitq_element_t; + +/* kew_flags defns */ +#define KWE_THREAD_INWAIT 1 +#define KWE_THREAD_PREPOST 2 +#define KWE_THREAD_BROADCAST 4 + + +#define WORKQUEUE_HIGH_PRIOQUEUE 0 /* high priority queue */ +#define WORKQUEUE_DEFAULT_PRIOQUEUE 1 /* default priority queue */ +#define WORKQUEUE_LOW_PRIOQUEUE 2 /* low priority queue */ +#define WORKQUEUE_BG_PRIOQUEUE 3 /* background priority queue */ + +#define WORKQUEUE_NUMPRIOS 4 #define WORKQUEUE_OVERCOMMIT 0x10000 @@ -42,7 +62,6 @@ struct threadlist { TAILQ_ENTRY(threadlist) th_entry; thread_t th_thread; int th_flags; - uint32_t th_suspended; uint16_t th_affinity_tag; uint8_t th_priority; uint8_t th_policy; @@ -57,41 +76,33 @@ struct threadlist { #define TH_LIST_BLOCKED 0x04 #define TH_LIST_SUSPENDED 0x08 #define TH_LIST_BUSY 0x10 +#define TH_LIST_NEED_WAKEUP 0x20 +#define TH_LIST_CONSTRAINED 0x40 -struct workitem { - TAILQ_ENTRY(workitem) wi_entry; - user_addr_t wi_item; - uint32_t wi_affinity; -}; - -struct workitemlist { - TAILQ_HEAD(, workitem) wl_itemlist; - TAILQ_HEAD(, workitem) wl_freelist; -}; struct workqueue { - struct workitem wq_array[WORKITEM_SIZE * WORKQUEUE_NUMPRIOS]; proc_t wq_proc; vm_map_t wq_map; task_t wq_task; thread_call_t wq_atimer_call; int wq_flags; int wq_lflags; - int wq_itemcount; uint64_t wq_thread_yielded_timestamp; uint32_t wq_thread_yielded_count; uint32_t wq_timer_interval; uint32_t wq_affinity_max; uint32_t wq_threads_scheduled; + uint32_t wq_constrained_threads_scheduled; uint32_t wq_nthreads; uint32_t wq_thidlecount; - uint32_t wq_reqconc[WORKQUEUE_NUMPRIOS]; /* requested concurrency for each priority level */ - struct workitemlist wq_list[WORKQUEUE_NUMPRIOS]; /* priority based item list */ - uint32_t wq_list_bitmap; + uint32_t wq_reqcount; TAILQ_HEAD(, threadlist) wq_thrunlist; TAILQ_HEAD(, threadlist) wq_thidlelist; - uint32_t *wq_thactive_count[WORKQUEUE_NUMPRIOS]; - uint32_t *wq_thscheduled_count[WORKQUEUE_NUMPRIOS]; + uint16_t wq_requests[WORKQUEUE_NUMPRIOS]; + uint16_t wq_ocrequests[WORKQUEUE_NUMPRIOS]; + uint16_t wq_reqconc[WORKQUEUE_NUMPRIOS]; /* requested concurrency for each priority level */ + uint16_t *wq_thscheduled_count[WORKQUEUE_NUMPRIOS]; + uint32_t *wq_thactive_count[WORKQUEUE_NUMPRIOS]; /* must be uint32_t since we OSAddAtomic on these */ uint64_t *wq_lastblocked_ts[WORKQUEUE_NUMPRIOS]; }; #define WQ_LIST_INITED 0x01 @@ -100,6 +111,8 @@ struct workqueue { #define WQL_ATIMER_BUSY 0x01 #define WQL_ATIMER_WAITING 0x02 +#define WQL_EXCEEDED_CONSTRAINED_THREAD_LIMIT 0x04 +#define WQL_EXCEEDED_TOTAL_THREAD_LIMIT 0x08 #define WQ_VECT_SET_BIT(vector, bit) \ @@ -121,20 +134,23 @@ struct workqueue { /* workq_kernreturn commands */ #define WQOPS_QUEUE_ADD 1 -#define WQOPS_QUEUE_REMOVE 2 +#define WQOPS_QUEUE_REMOVE_OBSOLETE 2 #define WQOPS_THREAD_RETURN 4 #define WQOPS_THREAD_SETCONC 8 +#define WQOPS_QUEUE_NEWSPISUPP 0x10 /* this is to check for newer SPI support */ +#define WQOPS_QUEUE_REQTHREADS 0x20 /* request number of threads of a prio */ #define PTH_DEFAULT_STACKSIZE 512*1024 #define PTH_DEFAULT_GUARDSIZE 4*1024 #define MAX_PTHREAD_SIZE 64*1024 -void workqueue_exit(struct proc *); - -void pthread_init(void); extern lck_grp_attr_t *pthread_lck_grp_attr; extern lck_grp_t *pthread_lck_grp; extern lck_attr_t *pthread_lck_attr; +void workqueue_mark_exiting(struct proc *); +void workqueue_exit(struct proc *); +void pthread_init(void); +void psynch_zoneinit(void); #endif /* _SYS_PTHREAD_INTERNAL_H_ */