-.\" $OpenBSD: timeout.9,v 1.52 2021/04/26 20:32:30 mvs Exp $
+.\" $OpenBSD: timeout.9,v 1.53 2021/05/11 13:29:25 cheloha Exp $
.\"
.\" Copyright (c) 2000 Artur Grabowski <art@openbsd.org>
.\" All rights reserved.
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: April 26 2021 $
+.Dd $Mdocdate: May 11 2021 $
.Dt TIMEOUT_SET 9
.Os
.Sh NAME
ensures that any current execution of the timeout in the argument
.Fa to
has completed before returning.
-If the timeout
-.Fa to
-has been initialised with
-.Fn timeout_set
-it will take the kernel lock.
.Pp
The
.Fn timeout_pending
-/* $OpenBSD: kern_timeout.c,v 1.83 2021/02/08 08:18:45 mpi Exp $ */
+/* $OpenBSD: kern_timeout.c,v 1.84 2021/05/11 13:29:25 cheloha Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
void softclock_process_kclock_timeout(struct timeout *, int);
void softclock_process_tick_timeout(struct timeout *, int);
void softclock_thread(void *);
+void timeout_barrier_timeout(void *);
uint32_t timeout_bucket(const struct timeout *);
uint32_t timeout_maskwheel(uint32_t, const struct timespec *);
void timeout_run(struct timeout *);
-void timeout_proc_barrier(void *);
/*
* The first thing in a struct timeout is its struct circq, so we
void
timeout_barrier(struct timeout *to)
{
- int needsproc = ISSET(to->to_flags, TIMEOUT_PROC);
+ struct timeout barrier;
+ struct cond c;
+ int procflag;
- timeout_sync_order(needsproc);
+ procflag = (to->to_flags & TIMEOUT_PROC);
+ timeout_sync_order(procflag);
- if (!needsproc) {
- KERNEL_LOCK();
- splx(splsoftclock());
- KERNEL_UNLOCK();
- } else {
- struct cond c = COND_INITIALIZER();
- struct timeout barrier;
+ timeout_set_flags(&barrier, timeout_barrier_timeout, &c, procflag);
+ barrier.to_process = curproc->p_p;
+ cond_init(&c);
- timeout_set_proc(&barrier, timeout_proc_barrier, &c);
- barrier.to_process = curproc->p_p;
+ mtx_enter(&timeout_mutex);
- mtx_enter(&timeout_mutex);
- SET(barrier.to_flags, TIMEOUT_ONQUEUE);
+ barrier.to_time = ticks;
+ SET(barrier.to_flags, TIMEOUT_ONQUEUE);
+ if (procflag)
CIRCQ_INSERT_TAIL(&timeout_proc, &barrier.to_list);
- mtx_leave(&timeout_mutex);
+ else
+ CIRCQ_INSERT_TAIL(&timeout_todo, &barrier.to_list);
+ mtx_leave(&timeout_mutex);
+
+ if (procflag)
wakeup_one(&timeout_proc);
+ else
+ softintr_schedule(softclock_si);
- cond_wait(&c, "tmobar");
- }
+ cond_wait(&c, "tmobar");
}
void
-timeout_proc_barrier(void *arg)
+timeout_barrier_timeout(void *arg)
{
struct cond *c = arg;