summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_umtx.c
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/kern/kern_umtx.c
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/kern/kern_umtx.c')
-rw-r--r--sys/kern/kern_umtx.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index 672add3..a4ee457 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -168,7 +168,7 @@ umtxq_busy(struct umtx_key *key)
while (umtxq_chains[chain].uc_flags & UCF_BUSY) {
umtxq_chains[chain].uc_flags |= UCF_WANT;
msleep(&umtxq_chains[chain], umtxq_mtx(chain),
- curthread->td_priority, "umtxq_busy", 0);
+ 0, "umtxq_busy", 0);
}
umtxq_chains[chain].uc_flags |= UCF_BUSY;
}
@@ -424,8 +424,7 @@ _do_lock(struct thread *td, struct umtx *umtx, long id, int timo)
*/
umtxq_lock(&uq->uq_key);
if (old == owner && (td->td_flags & TDF_UMTXQ)) {
- error = umtxq_sleep(td, &uq->uq_key,
- td->td_priority | PCATCH,
+ error = umtxq_sleep(td, &uq->uq_key, PCATCH,
"umtx", timo);
}
umtxq_busy(&uq->uq_key);
@@ -547,7 +546,7 @@ do_wait(struct thread *td, struct umtx *umtx, long id, struct timespec *timeout)
umtxq_lock(&uq->uq_key);
if (td->td_flags & TDF_UMTXQ)
error = umtxq_sleep(td, &uq->uq_key,
- td->td_priority | PCATCH, "ucond", 0);
+ PCATCH, "ucond", 0);
if (!(td->td_flags & TDF_UMTXQ))
error = 0;
else
@@ -560,8 +559,7 @@ do_wait(struct thread *td, struct umtx *umtx, long id, struct timespec *timeout)
for (;;) {
umtxq_lock(&uq->uq_key);
if (td->td_flags & TDF_UMTXQ) {
- error = umtxq_sleep(td, &uq->uq_key,
- td->td_priority | PCATCH,
+ error = umtxq_sleep(td, &uq->uq_key, PCATCH,
"ucond", tvtohz(&tv));
}
if (!(td->td_flags & TDF_UMTXQ)) {
OpenPOWER on IntegriCloud