Lines Matching refs:thread
93 pthread_t thread = v; in _rthread_start() local
96 retval = thread->fn(thread->arg); in _rthread_start()
154 _rthread_free(pthread_t thread) in _rthread_free() argument
157 TAILQ_INSERT_TAIL(&_thread_gc_list, thread, waiting); in _rthread_free()
162 _thread_release(pthread_t thread) in _thread_release() argument
165 LIST_REMOVE(thread, threads); in _thread_release()
168 _spinlock(&thread->flags_lock); in _thread_release()
169 if (thread->flags & THREAD_DETACHED) { in _thread_release()
170 _spinunlock(&thread->flags_lock); in _thread_release()
171 _rthread_free(thread); in _thread_release()
173 thread->flags |= THREAD_DONE; in _thread_release()
174 _spinunlock(&thread->flags_lock); in _thread_release()
175 _sem_post(&thread->donesem); in _thread_release()
182 pthread_t thread; in _thread_key_zero() local
185 LIST_FOREACH(thread, &_thread_list, threads) { in _thread_key_zero()
186 for (rs = thread->local_storage; rs; rs = rs->next) { in _thread_key_zero()
196 pthread_t thread = pthread_self(); in _rthread_init() local
202 LIST_INSERT_HEAD(&_thread_list, thread, threads); in _rthread_init()
206 thread->attr = _rthread_attr_default; in _rthread_init()
250 pthread_t thread; in _rthread_reaper() local
254 TAILQ_FOREACH(thread, &_thread_gc_list, waiting) { in _rthread_reaper()
255 if (thread->tib->tib_tid != 0) in _rthread_reaper()
257 TAILQ_REMOVE(&_thread_gc_list, thread, waiting); in _rthread_reaper()
259 if (thread != &_initial_thread) { in _rthread_reaper()
261 (void *)thread, (void *)thread->stack); in _rthread_reaper()
262 _rthread_free_stack(thread->stack); in _rthread_reaper()
263 _dl_free_tib(thread->tib, sizeof(*thread)); in _rthread_reaper()
267 (void *)thread); in _rthread_reaper()
268 _dl_free_tib(thread->tib, 0); in _rthread_reaper()
280 pthread_join(pthread_t thread, void **retval) in pthread_join() argument
298 if (thread == NULL) in pthread_join()
300 else if (thread == self) in pthread_join()
302 else if (thread->flags & THREAD_DETACHED) in pthread_join()
304 else if ((e = _sem_wait(&thread->donesem, 0, NULL, in pthread_join()
307 *retval = thread->retval; in pthread_join()
314 if ((thread->flags & THREAD_DETACHED) == 0) in pthread_join()
315 _rthread_free(thread); in pthread_join()
324 pthread_detach(pthread_t thread) in pthread_detach() argument
328 _spinlock(&thread->flags_lock); in pthread_detach()
329 if (thread->flags & THREAD_DETACHED) { in pthread_detach()
331 _spinunlock(&thread->flags_lock); in pthread_detach()
332 } else if (thread->flags & THREAD_DONE) { in pthread_detach()
333 _spinunlock(&thread->flags_lock); in pthread_detach()
334 _rthread_free(thread); in pthread_detach()
336 thread->flags |= THREAD_DETACHED; in pthread_detach()
337 _spinunlock(&thread->flags_lock); in pthread_detach()
349 pthread_t thread; in pthread_create() local
358 tib = _dl_allocate_tib(sizeof(*thread)); in pthread_create()
361 thread = tib->tib_thread; in pthread_create()
362 memset(thread, 0, sizeof(*thread)); in pthread_create()
363 thread->tib = tib; in pthread_create()
364 thread->donesem.lock = _SPINLOCK_UNLOCKED; in pthread_create()
365 thread->flags_lock = _SPINLOCK_UNLOCKED; in pthread_create()
366 thread->fn = start_routine; in pthread_create()
367 thread->arg = arg; in pthread_create()
370 thread->attr = attr != NULL ? *(*attr) : _rthread_attr_default; in pthread_create()
371 if (thread->attr.sched_inherit == PTHREAD_INHERIT_SCHED) { in pthread_create()
374 thread->attr.sched_policy = self->attr.sched_policy; in pthread_create()
375 thread->attr.sched_param = self->attr.sched_param; in pthread_create()
377 if (thread->attr.detach_state == PTHREAD_CREATE_DETACHED) in pthread_create()
378 thread->flags |= THREAD_DETACHED; in pthread_create()
380 thread->stack = _rthread_alloc_stack(thread); in pthread_create()
381 if (!thread->stack) { in pthread_create()
388 param.tf_stack = thread->stack->sp; in pthread_create()
391 LIST_INSERT_HEAD(&_thread_list, thread, threads); in pthread_create()
396 rc = __tfork_thread(¶m, sizeof(param), _rthread_start, thread); in pthread_create()
399 *threadp = thread; in pthread_create()
406 LIST_REMOVE(thread, threads); in pthread_create()
408 _rthread_free_stack(thread->stack); in pthread_create()
410 _dl_free_tib(tib, sizeof(*thread)); in pthread_create()
416 pthread_kill(pthread_t thread, int sig) in pthread_kill() argument
418 struct tib *tib = thread->tib; in pthread_kill()
428 pthread_cancel(pthread_t thread) in pthread_cancel() argument
430 struct tib *tib = thread->tib; in pthread_cancel()
548 pthread_t thread; in _thread_dump_info() local
551 LIST_FOREACH(thread, &_thread_list, threads) in _thread_dump_info()
552 printf("thread %d flags 0x%x name %s\n", thread->tib->tib_tid, in _thread_dump_info()
553 thread->tib->tib_thread_flags, thread->name); in _thread_dump_info()