X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/9bccf70c0258c7cac2dcb80011b2a964d884c552..5eebf7385fedb1517b66b53c28e5aa6bb0a2be50:/osfmk/kern/wait_queue.c?ds=inline diff --git a/osfmk/kern/wait_queue.c b/osfmk/kern/wait_queue.c index d44cd9ec9..eef777359 100644 --- a/osfmk/kern/wait_queue.c +++ b/osfmk/kern/wait_queue.c @@ -832,6 +832,7 @@ wait_queue_unlink_one( * * Conditions: * The wait queue is assumed locked. + * The waiting thread is assumed locked. * */ __private_extern__ wait_result_t @@ -839,18 +840,18 @@ wait_queue_assert_wait64_locked( wait_queue_t wq, event64_t event, wait_interrupt_t interruptible, - boolean_t unlock) + thread_t thread) { - thread_t thread; wait_result_t wait_result; + if (!wait_queue_assert_possible(thread)) + panic("wait_queue_assert_wait64_locked"); + if (wq->wq_type == _WAIT_QUEUE_SET_inited) { wait_queue_set_t wqs = (wait_queue_set_t)wq; - if (wqs->wqs_isprepost && wqs->wqs_refcount > 0) { - if (unlock) - wait_queue_unlock(wq); + + if (wqs->wqs_isprepost && wqs->wqs_refcount > 0) return(THREAD_AWAKENED); - } } /* @@ -859,8 +860,6 @@ wait_queue_assert_wait64_locked( * the front of the queue. Later, these queues will honor the policy * value set at wait_queue_init time. */ - thread = current_thread(); - thread_lock(thread); wait_result = thread_mark_wait_locked(thread, interruptible); if (wait_result == THREAD_WAITING) { if (thread->vm_privilege) @@ -870,9 +869,6 @@ wait_queue_assert_wait64_locked( thread->wait_event = event; thread->wait_queue = wq; } - thread_unlock(thread); - if (unlock) - wait_queue_unlock(wq); return(wait_result); } @@ -893,6 +889,7 @@ wait_queue_assert_wait( { spl_t s; wait_result_t ret; + thread_t cur_thread = current_thread(); /* If it is an invalid wait queue, you can't wait on it */ if (!wait_queue_is_valid(wq)) { @@ -902,10 +899,12 @@ wait_queue_assert_wait( s = splsched(); wait_queue_lock(wq); + thread_lock(cur_thread); ret = wait_queue_assert_wait64_locked( wq, (event64_t)((uint32_t)event), - interruptible, TRUE); - /* wait queue unlocked */ + interruptible, cur_thread); + thread_unlock(cur_thread); + wait_queue_unlock(wq); splx(s); return(ret); } @@ -926,6 +925,7 @@ wait_queue_assert_wait64( { spl_t s; wait_result_t ret; + thread_t cur_thread = current_thread(); /* If it is an invalid wait queue, you cant wait on it */ if (!wait_queue_is_valid(wq)) { @@ -935,8 +935,10 @@ wait_queue_assert_wait64( s = splsched(); wait_queue_lock(wq); - ret = wait_queue_assert_wait64_locked(wq, event, interruptible, TRUE); - /* wait queue unlocked */ + thread_lock(cur_thread); + ret = wait_queue_assert_wait64_locked(wq, event, interruptible, cur_thread); + thread_unlock(cur_thread); + wait_queue_unlock(wq); splx(s); return(ret); }