* Create a zthr with specified maximum sleep time. If the time * in sleeping state exceeds max_sleep, a wakeup(do the check and * start working if required) will be triggered. */
| 281 | * start working if required) will be triggered. |
| 282 | */ |
| 283 | zthr_t * |
| 284 | zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc, |
| 285 | zthr_func_t *func, void *arg, hrtime_t max_sleep) |
| 286 | { |
| 287 | zthr_t *t = kmem_zalloc(sizeof (*t), KM_SLEEP); |
| 288 | mutex_init(&t->zthr_state_lock, NULL, MUTEX_DEFAULT, NULL); |
| 289 | mutex_init(&t->zthr_request_lock, NULL, MUTEX_DEFAULT, NULL); |
| 290 | cv_init(&t->zthr_cv, NULL, CV_DEFAULT, NULL); |
| 291 | cv_init(&t->zthr_wait_cv, NULL, CV_DEFAULT, NULL); |
| 292 | |
| 293 | mutex_enter(&t->zthr_state_lock); |
| 294 | t->zthr_checkfunc = checkfunc; |
| 295 | t->zthr_func = func; |
| 296 | t->zthr_arg = arg; |
| 297 | t->zthr_sleep_timeout = max_sleep; |
| 298 | t->zthr_name = zthr_name; |
| 299 | |
| 300 | t->zthr_thread = thread_create_named(zthr_name, NULL, 0, |
| 301 | zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri); |
| 302 | |
| 303 | mutex_exit(&t->zthr_state_lock); |
| 304 | |
| 305 | return (t); |
| 306 | } |
| 307 | |
| 308 | void |
| 309 | zthr_destroy(zthr_t *t) |
no test coverage detected