-/* $OpenBSD: kern_task.c,v 1.21 2017/11/13 23:52:49 dlg Exp $ */
+/* $OpenBSD: kern_task.c,v 1.22 2017/12/14 00:45:16 dlg Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
void
taskq_barrier(struct taskq *tq)
{
- struct sleep_state sls;
- unsigned int notdone = 1;
- struct task t = TASK_INITIALIZER(taskq_barrier_task, ¬done);
+ struct cond c = COND_INITIALIZER();
+ struct task t = TASK_INITIALIZER(taskq_barrier_task, &c);
task_add(tq, &t);
- while (notdone) {
- sleep_setup(&sls, ¬done, PWAIT, "tqbar");
- sleep_finish(&sls, notdone);
- }
+ cond_wait(&c, "tqbar");
}
void
taskq_barrier_task(void *p)
{
- unsigned int *notdone = p;
-
- *notdone = 0;
- wakeup_one(notdone);
+ struct cond *c = p;
+ cond_signal(c);
}
void
-/* $OpenBSD: kern_timeout.c,v 1.51 2017/11/24 02:36:53 dlg Exp $ */
+/* $OpenBSD: kern_timeout.c,v 1.52 2017/12/14 00:45:16 dlg Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
splx(splsoftclock());
KERNEL_UNLOCK();
} else {
- int wait = 1;
+ struct cond c = COND_INITIALIZER();
struct timeout barrier;
- struct sleep_state sls;
- timeout_set_proc(&barrier, timeout_proc_barrier, &wait);
+ timeout_set_proc(&barrier, timeout_proc_barrier, &c);
mtx_enter(&timeout_mutex);
barrier.to_flags |= TIMEOUT_ONQUEUE;
wakeup_one(&timeout_proc);
- while (wait) {
- sleep_setup(&sls, &wait, PSWP, "tmobar");
- sleep_finish(&sls, wait);
- }
+ cond_wait(&c, "tmobar");
}
}
-/* $OpenBSD: ifq.c,v 1.15 2017/11/14 08:44:11 dlg Exp $ */
+/* $OpenBSD: ifq.c,v 1.16 2017/12/14 00:45:16 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
void
ifq_barrier(struct ifqueue *ifq)
{
- struct sleep_state sls;
- unsigned int notdone = 1;
- struct task t = TASK_INITIALIZER(ifq_barrier_task, ¬done);
+ struct cond c = COND_INITIALIZER();
+ struct task t = TASK_INITIALIZER(ifq_barrier_task, &c);
/* this should only be called from converted drivers */
KASSERT(ISSET(ifq->ifq_if->if_xflags, IFXF_MPSAFE));
ifq_serialize(ifq, &t);
- while (notdone) {
- sleep_setup(&sls, ¬done, PWAIT, "ifqbar");
- sleep_finish(&sls, notdone);
- }
+ cond_wait(&c, "ifqbar");
}
void