Lines Matching refs:t
237 zthr_t *t = arg; in zthr_procedure() local
239 mutex_enter(&t->zthr_state_lock); in zthr_procedure()
240 ASSERT3P(t->zthr_thread, ==, curthread); in zthr_procedure()
242 while (!t->zthr_cancel) { in zthr_procedure()
243 if (t->zthr_checkfunc(t->zthr_arg, t)) { in zthr_procedure()
244 mutex_exit(&t->zthr_state_lock); in zthr_procedure()
245 t->zthr_func(t->zthr_arg, t); in zthr_procedure()
246 mutex_enter(&t->zthr_state_lock); in zthr_procedure()
248 if (t->zthr_sleep_timeout == 0) { in zthr_procedure()
249 cv_wait_idle(&t->zthr_cv, &t->zthr_state_lock); in zthr_procedure()
251 (void) cv_timedwait_idle_hires(&t->zthr_cv, in zthr_procedure()
252 &t->zthr_state_lock, t->zthr_sleep_timeout, in zthr_procedure()
256 if (t->zthr_haswaiters) { in zthr_procedure()
257 t->zthr_haswaiters = B_FALSE; in zthr_procedure()
258 cv_broadcast(&t->zthr_wait_cv); in zthr_procedure()
266 t->zthr_thread = NULL; in zthr_procedure()
267 t->zthr_cancel = B_FALSE; in zthr_procedure()
268 cv_broadcast(&t->zthr_cv); in zthr_procedure()
270 mutex_exit(&t->zthr_state_lock); in zthr_procedure()
291 zthr_t *t = kmem_zalloc(sizeof (*t), KM_SLEEP); in zthr_create_timer() local
292 mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL); in zthr_create_timer()
293 mutex_init(&t->zthr_request_lock, NULL, MUTEX_DEFAULT, NULL); in zthr_create_timer()
294 cv_init(&t->zthr_cv, NULL, CV_DEFAULT, NULL); in zthr_create_timer()
295 cv_init(&t->zthr_wait_cv, NULL, CV_DEFAULT, NULL); in zthr_create_timer()
297 mutex_enter(&t->zthr_state_lock); in zthr_create_timer()
298 t->zthr_checkfunc = checkfunc; in zthr_create_timer()
299 t->zthr_func = func; in zthr_create_timer()
300 t->zthr_arg = arg; in zthr_create_timer()
301 t->zthr_sleep_timeout = max_sleep; in zthr_create_timer()
302 t->zthr_name = zthr_name; in zthr_create_timer()
303 t->zthr_pri = pri; in zthr_create_timer()
305 t->zthr_thread = thread_create_named(zthr_name, NULL, 0, in zthr_create_timer()
306 zthr_procedure, t, 0, &p0, TS_RUN, pri); in zthr_create_timer()
308 mutex_exit(&t->zthr_state_lock); in zthr_create_timer()
310 return (t); in zthr_create_timer()
314 zthr_destroy(zthr_t *t) in zthr_destroy() argument
316 ASSERT(!MUTEX_HELD(&t->zthr_state_lock)); in zthr_destroy()
317 ASSERT(!MUTEX_HELD(&t->zthr_request_lock)); in zthr_destroy()
318 VERIFY3P(t->zthr_thread, ==, NULL); in zthr_destroy()
319 mutex_destroy(&t->zthr_request_lock); in zthr_destroy()
320 mutex_destroy(&t->zthr_state_lock); in zthr_destroy()
321 cv_destroy(&t->zthr_cv); in zthr_destroy()
322 cv_destroy(&t->zthr_wait_cv); in zthr_destroy()
323 kmem_free(t, sizeof (*t)); in zthr_destroy()
331 zthr_wakeup(zthr_t *t) in zthr_wakeup() argument
333 mutex_enter(&t->zthr_state_lock); in zthr_wakeup()
352 cv_broadcast(&t->zthr_cv); in zthr_wakeup()
354 mutex_exit(&t->zthr_state_lock); in zthr_wakeup()
364 zthr_cancel(zthr_t *t) in zthr_cancel() argument
366 mutex_enter(&t->zthr_request_lock); in zthr_cancel()
367 mutex_enter(&t->zthr_state_lock); in zthr_cancel()
386 if (t->zthr_thread != NULL) { in zthr_cancel()
387 t->zthr_cancel = B_TRUE; in zthr_cancel()
390 cv_broadcast(&t->zthr_cv); in zthr_cancel()
392 while (t->zthr_thread != NULL) in zthr_cancel()
393 cv_wait(&t->zthr_cv, &t->zthr_state_lock); in zthr_cancel()
395 ASSERT(!t->zthr_cancel); in zthr_cancel()
398 mutex_exit(&t->zthr_state_lock); in zthr_cancel()
399 mutex_exit(&t->zthr_request_lock); in zthr_cancel()
408 zthr_resume(zthr_t *t) in zthr_resume() argument
410 mutex_enter(&t->zthr_request_lock); in zthr_resume()
411 mutex_enter(&t->zthr_state_lock); in zthr_resume()
413 ASSERT3P(&t->zthr_checkfunc, !=, NULL); in zthr_resume()
414 ASSERT3P(&t->zthr_func, !=, NULL); in zthr_resume()
415 ASSERT(!t->zthr_cancel); in zthr_resume()
416 ASSERT(!t->zthr_haswaiters); in zthr_resume()
429 if (t->zthr_thread == NULL) { in zthr_resume()
430 t->zthr_thread = thread_create_named(t->zthr_name, NULL, 0, in zthr_resume()
431 zthr_procedure, t, 0, &p0, TS_RUN, t->zthr_pri); in zthr_resume()
434 mutex_exit(&t->zthr_state_lock); in zthr_resume()
435 mutex_exit(&t->zthr_request_lock); in zthr_resume()
450 zthr_iscancelled(zthr_t *t) in zthr_iscancelled() argument
452 ASSERT3P(t->zthr_thread, ==, curthread); in zthr_iscancelled()
466 mutex_enter(&t->zthr_state_lock); in zthr_iscancelled()
467 boolean_t cancelled = t->zthr_cancel; in zthr_iscancelled()
468 mutex_exit(&t->zthr_state_lock); in zthr_iscancelled()
473 zthr_iscurthread(zthr_t *t) in zthr_iscurthread() argument
475 return (t->zthr_thread == curthread); in zthr_iscurthread()
485 zthr_wait_cycle_done(zthr_t *t) in zthr_wait_cycle_done() argument
487 mutex_enter(&t->zthr_state_lock); in zthr_wait_cycle_done()
509 if (t->zthr_thread != NULL) { in zthr_wait_cycle_done()
510 t->zthr_haswaiters = B_TRUE; in zthr_wait_cycle_done()
513 cv_broadcast(&t->zthr_cv); in zthr_wait_cycle_done()
515 while ((t->zthr_haswaiters) && (t->zthr_thread != NULL)) in zthr_wait_cycle_done()
516 cv_wait(&t->zthr_wait_cv, &t->zthr_state_lock); in zthr_wait_cycle_done()
518 ASSERT(!t->zthr_haswaiters); in zthr_wait_cycle_done()
521 mutex_exit(&t->zthr_state_lock); in zthr_wait_cycle_done()
533 zthr_has_waiters(zthr_t *t) in zthr_has_waiters() argument
535 ASSERT3P(t->zthr_thread, ==, curthread); in zthr_has_waiters()
537 mutex_enter(&t->zthr_state_lock); in zthr_has_waiters()
544 boolean_t has_waiters = t->zthr_haswaiters; in zthr_has_waiters()
545 mutex_exit(&t->zthr_state_lock); in zthr_has_waiters()