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

Function _cv_timedwait_sbt

freebsd/kern/kern_condvar.c:272–325  ·  view source on GitHub ↗

* Wait on a condition variable for (at most) the value specified in sbt * argument. Returns 0 if the process was resumed by cv_signal or cv_broadcast, * EWOULDBLOCK if the timeout expires. */

Source from the content-addressed store, hash-verified

270 * EWOULDBLOCK if the timeout expires.
271 */
272int
273_cv_timedwait_sbt(struct cv *cvp, struct lock_object *lock, sbintime_t sbt,
274 sbintime_t pr, int flags)
275{
276 WITNESS_SAVE_DECL(lock_witness);
277 struct lock_class *class;
278 struct thread *td;
279 int lock_state, rval;
280
281 td = curthread;
282 lock_state = 0;
283#ifdef KTRACE
284 if (KTRPOINT(td, KTR_CSW))
285 ktrcsw(1, 0, cv_wmesg(cvp));
286#endif
287 CV_ASSERT(cvp, lock, td);
288 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, lock,
289 "Waiting on \"%s\"", cvp->cv_description);
290 class = LOCK_CLASS(lock);
291
292 if (SCHEDULER_STOPPED_TD(td))
293 return (0);
294
295 sleepq_lock(cvp);
296
297 CV_WAITERS_INC(cvp);
298 if (lock == &Giant.lock_object)
299 mtx_assert(&Giant, MA_OWNED);
300 DROP_GIANT();
301
302 sleepq_add(cvp, lock, cvp->cv_description, SLEEPQ_CONDVAR, 0);
303 sleepq_set_timeout_sbt(cvp, sbt, pr, flags);
304 if (lock != &Giant.lock_object) {
305 if (class->lc_flags & LC_SLEEPABLE)
306 sleepq_release(cvp);
307 WITNESS_SAVE(lock, lock_witness);
308 lock_state = class->lc_unlock(lock);
309 if (class->lc_flags & LC_SLEEPABLE)
310 sleepq_lock(cvp);
311 }
312 rval = sleepq_timedwait(cvp, 0);
313
314#ifdef KTRACE
315 if (KTRPOINT(td, KTR_CSW))
316 ktrcsw(0, 0, cv_wmesg(cvp));
317#endif
318 PICKUP_GIANT();
319 if (lock != &Giant.lock_object) {
320 class->lc_lock(lock, lock_state);
321 WITNESS_RESTORE(lock, lock_witness);
322 }
323
324 return (rval);
325}
326
327/*
328 * Wait on a condition variable for (at most) the value specified in sbt

Callers 1

cv_timedwaitFunction · 0.85

Calls 7

ktrcswFunction · 0.85
sleepq_lockFunction · 0.85
mtx_assertFunction · 0.85
sleepq_addFunction · 0.85
sleepq_set_timeout_sbtFunction · 0.85
sleepq_releaseFunction · 0.85
sleepq_timedwaitFunction · 0.85

Tested by

no test coverage detected