summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sensors.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2005-11-10 08:32:57 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2005-11-10 08:32:57 +0000
commit462d625c0dac39788a93e6d4563c1bf3ca65f874 (patch)
tree60054f5a50eab892da6e82780009507e6f0dc78f /sys/kern/kern_sensors.c
parent5e4a1f6b637012256feea806e28d526ddc62f6ab (diff)
the tasklist can be modified while the kthread is sleeping, so refetch
the first element before iterating through the rest of them. stylistic guidance from angela pascoe. mark all tasks using the same argument as not running anymore, rather than just the first one we bump into.
Diffstat (limited to 'sys/kern/kern_sensors.c')
-rw-r--r--sys/kern/kern_sensors.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/kern/kern_sensors.c b/sys/kern/kern_sensors.c
index b8c0bd85304..83cc25b823b 100644
--- a/sys/kern/kern_sensors.c
+++ b/sys/kern/kern_sensors.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sensors.c,v 1.2 2005/11/10 08:20:20 dlg Exp $ */
+/* $OpenBSD: kern_sensors.c,v 1.3 2005/11/10 08:32:56 dlg Exp $ */
/*
* Copyright (c) 2005 David Gwynne <dlg@openbsd.org>
@@ -65,6 +65,7 @@ sensor_task_register(void *arg, void (*func)(void *), int period)
kthread_create_deferred(sensor_task_create, NULL);
sensor_task_schedule(st);
+ wakeup(&tasklist);
return (0);
}
@@ -78,10 +79,8 @@ sensor_task_unregister(void *arg)
while ((st = nst) != NULL) {
nst = TAILQ_NEXT(st, entry);
- if (st->arg == arg) {
+ if (st->arg == arg)
st->running = 0;
- return;
- }
}
}
@@ -101,7 +100,8 @@ sensor_task_thread(void *arg)
while (!TAILQ_EMPTY(&tasklist)) {
nst = TAILQ_FIRST(&tasklist);
- while (nst->nextrun > (now = time_uptime))
+ while ((nst = TAILQ_FIRST(&tasklist))->nextrun >
+ (now = time_uptime))
tsleep(&tasklist, PWAIT, "timeout",
(nst->nextrun - now) * hz);