MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zthr_create_timer

Function zthr_create_timer

freebsd/contrib/openzfs/module/zfs/zthr.c:283–306  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

281 * start working if required) will be triggered.
282 */
283zthr_t *
284zthr_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
308void
309zthr_destroy(zthr_t *t)

Callers 2

arc_initFunction · 0.85
zthr_createFunction · 0.85

Calls 4

mutex_enterFunction · 0.85
mutex_exitFunction · 0.85
mutex_initFunction · 0.50
cv_initFunction · 0.50

Tested by

no test coverage detected