Lines Matching refs:thread

83 static void thr_destroy(pthread_t curthread, pthread_t thread);
152 pthread_t thread = NULL; in _thr_alloc() local
160 if ((thread = TAILQ_FIRST(&free_threadq)) != NULL) { in _thr_alloc()
161 TAILQ_REMOVE(&free_threadq, thread, tle); in _thr_alloc()
167 if (thread == NULL) { in _thr_alloc()
168 thread = __malloc(sizeof(struct __pthread_s)); in _thr_alloc()
169 if (thread == NULL) in _thr_alloc()
174 tcb = _tcb_ctor(thread, 0 /* not initial tls */); in _thr_alloc()
177 tcb = _tcb_ctor(thread, 1 /* initial tls */); in _thr_alloc()
180 memset(thread, 0, sizeof(*thread)); in _thr_alloc()
181 thread->tcb = tcb; in _thr_alloc()
183 thr_destroy(curthread, thread); in _thr_alloc()
184 thread = NULL; in _thr_alloc()
186 return (thread); in _thr_alloc()
190 _thr_free(pthread_t curthread, pthread_t thread) in _thr_free() argument
192 DBG_MSG("Freeing thread %p\n", thread); in _thr_free()
193 if (thread->name) { in _thr_free()
194 __free(thread->name); in _thr_free()
195 thread->name = NULL; in _thr_free()
204 _tcb_dtor(thread->tcb); in _thr_free()
207 _tcb_dtor(thread->tcb); in _thr_free()
209 thread->tcb = NULL; in _thr_free()
211 thr_destroy(curthread, thread); in _thr_free()
218 TAILQ_INSERT_TAIL(&free_threadq, thread, tle); in _thr_free()
225 thr_destroy(pthread_t curthread __unused, pthread_t thread) in thr_destroy() argument
227 __free(thread); in thr_destroy()
239 _thr_link(pthread_t curthread, pthread_t thread) in _thr_link() argument
247 thread->uniqueid = next_uniqueid++; in _thr_link()
248 THR_LIST_ADD(thread); in _thr_link()
257 _thr_unlink(pthread_t curthread, pthread_t thread) in _thr_unlink() argument
260 THR_LIST_REMOVE(thread); in _thr_unlink()
266 _thr_hash_add(pthread_t thread) in _thr_hash_add() argument
270 head = &thr_hashtable[THREAD_HASH(thread)]; in _thr_hash_add()
271 LIST_INSERT_HEAD(head, thread, hle); in _thr_hash_add()
275 _thr_hash_remove(pthread_t thread) in _thr_hash_remove() argument
277 LIST_REMOVE(thread, hle); in _thr_hash_remove()
281 _thr_hash_find(pthread_t thread) in _thr_hash_find() argument
286 head = &thr_hashtable[THREAD_HASH(thread)]; in _thr_hash_find()
288 if (td == thread) in _thr_hash_find()
289 return (thread); in _thr_hash_find()
300 _thr_ref_add(pthread_t curthread, pthread_t thread, in _thr_ref_add() argument
305 if (thread == NULL) in _thr_ref_add()
310 if ((ret = _thr_find_thread(curthread, thread, include_dead)) == 0) { in _thr_ref_add()
311 thread->refcount++; in _thr_ref_add()
320 _thr_ref_delete(pthread_t curthread, pthread_t thread) in _thr_ref_delete() argument
323 _thr_ref_delete_unlocked(curthread, thread); in _thr_ref_delete()
328 _thr_ref_delete_unlocked(pthread_t curthread __unused, pthread_t thread) in _thr_ref_delete_unlocked() argument
330 if (thread != NULL) { in _thr_ref_delete_unlocked()
331 thread->refcount--; in _thr_ref_delete_unlocked()
332 if ((thread->refcount == 0) && thread->state == PS_DEAD && in _thr_ref_delete_unlocked()
333 (thread->tlflags & TLFLAGS_DETACHED) != 0) in _thr_ref_delete_unlocked()
334 THR_GCLIST_ADD(thread); in _thr_ref_delete_unlocked()
339 _thr_find_thread(pthread_t curthread __unused, pthread_t thread, in _thr_find_thread() argument
344 if (thread == NULL) in _thr_find_thread()
347 pthread = _thr_hash_find(thread); in _thr_find_thread()