Lines Matching refs:mtx
687 struct rumpuser_mtx *mtx;
689 mtx = malloc(sizeof(*mtx));
690 memset(mtx, 0, sizeof(*mtx));
691 mtx->flags = flags;
692 TAILQ_INIT(&mtx->waiters);
693 *mtxp = mtx;
697 rumpuser_mutex_spin_p(struct rumpuser_mtx *mtx)
700 return (mtx->flags & RUMPUSER_MTX_SPIN) != 0;
704 rumpuser_mutex_enter(struct rumpuser_mtx *mtx)
708 if (rumpuser_mutex_tryenter(mtx) != 0) {
710 while (rumpuser_mutex_tryenter(mtx) != 0)
711 wait(&mtx->waiters, 0);
717 rumpuser_mutex_enter_nowrap(struct rumpuser_mtx *mtx)
721 rv = rumpuser_mutex_tryenter(mtx);
729 rumpuser_mutex_tryenter(struct rumpuser_mtx *mtx)
733 if (mtx->v && mtx->o != l)
736 mtx->v++;
737 mtx->o = l;
743 rumpuser_mutex_exit(struct rumpuser_mtx *mtx)
746 assert(mtx->v > 0);
747 if (--mtx->v == 0) {
748 mtx->o = NULL;
749 wakeup_one(&mtx->waiters);
754 rumpuser_mutex_destroy(struct rumpuser_mtx *mtx)
757 assert(TAILQ_EMPTY(&mtx->waiters) && mtx->o == NULL);
758 free(mtx);
762 rumpuser_mutex_owner(struct rumpuser_mtx *mtx, struct lwp **lp)
765 *lp = mtx->o;
929 cv_unsched(struct rumpuser_mtx *mtx, int *nlocks)
932 rumpkern_unsched(nlocks, mtx);
933 rumpuser_mutex_exit(mtx);
937 cv_resched(struct rumpuser_mtx *mtx, int nlocks)
941 if ((mtx->flags & (RUMPUSER_MTX_KMUTEX | RUMPUSER_MTX_SPIN)) ==
943 rumpkern_sched(nlocks, mtx);
944 rumpuser_mutex_enter_nowrap(mtx);
946 rumpuser_mutex_enter_nowrap(mtx);
947 rumpkern_sched(nlocks, mtx);
952 rumpuser_cv_wait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx)
957 cv_unsched(mtx, &nlocks);
959 cv_resched(mtx, nlocks);
964 rumpuser_cv_wait_nowrap(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx)
968 rumpuser_mutex_exit(mtx);
970 rumpuser_mutex_enter_nowrap(mtx);
975 rumpuser_cv_timedwait(struct rumpuser_cv *cv, struct rumpuser_mtx *mtx,
982 cv_unsched(mtx, &nlocks);
984 cv_resched(mtx, nlocks);