summaryrefslogtreecommitdiffstats
path: root/sys/dev/hwpmc
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-04-17 18:20:38 +0000
committerjhb <jhb@FreeBSD.org>2006-04-17 18:20:38 +0000
commitd535a5cb818e93fdb882b2748621d7367c013113 (patch)
tree6e1e68443c878ae084bc35e7e36a8edf68ad3352 /sys/dev/hwpmc
parentb4b950d049176bd4834f960bca79c4a2bdfd88c4 (diff)
downloadFreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.zip
FreeBSD-src-d535a5cb818e93fdb882b2748621d7367c013113.tar.gz
Change msleep() and tsleep() to not alter the calling thread's priority
if the specified priority is zero. This avoids a race where the calling thread could read a snapshot of it's current priority, then a different thread could change the first thread's priority, then the original thread would call sched_prio() inside msleep() undoing the change made by the second thread. I used a priority of zero as no thread that calls msleep() or tsleep() should be specifying a priority of zero anyway. The various places that passed 'curthread->td_priority' or some variant as the priority now pass 0.
Diffstat (limited to 'sys/dev/hwpmc')
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 1ea0e68..579b6fd 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -646,15 +646,8 @@ pmc_select_cpu(int cpu)
static void
pmc_force_context_switch(void)
{
- u_char curpri;
-
- mtx_lock_spin(&sched_lock);
- curpri = curthread->td_priority;
- mtx_unlock_spin(&sched_lock);
-
- (void) tsleep((void *) pmc_force_context_switch, curpri,
- "pmcctx", 1);
+ (void) tsleep((void *) pmc_force_context_switch, 0, "pmcctx", 1);
}
/*
OpenPOWER on IntegriCloud