Lines Matching refs:thread

66 #include <kern/thread.h>
498 thread_t thread = current_thread();
509 * during the time that this thread is asleep, so that when it
513 thread->rwlock_count++;
532 if ((thread->rwlock_count-- == 1 /* field now 0 */) && (thread->sched_flags & TH_SFLAG_RW_PROMOTED)) {
534 lck_rw_clear_promotion(thread);
556 thread_t thread = current_thread();
568 thread->rwlock_count++;
587 if ((thread->rwlock_count-- == 1 /* field now 0 */) && (thread->sched_flags & TH_SFLAG_RW_PROMOTED)) {
589 lck_rw_clear_promotion(thread);
702 thread_t thread = current_thread();
710 if (thread->pending_promoter[thread->pending_promoter_index] == mutex) {
711 thread->pending_promoter[thread->pending_promoter_index] = NULL;
712 if (thread->pending_promoter_index > 0)
713 thread->pending_promoter_index--;
721 thread_lock(thread);
722 thread->promotions++;
723 thread->sched_flags |= TH_SFLAG_PROMOTED;
724 if (thread->sched_pri < priority) {
727 thread->sched_pri, priority, 0, lck, 0);
730 set_sched_pri(thread, priority);
732 thread_unlock(thread);
762 thread_t thread = current_thread();
770 if (thread != holder)
778 if (thread->promotions > 0) {
781 thread_lock(thread);
782 if ( --thread->promotions == 0 &&
783 (thread->sched_flags & TH_SFLAG_PROMOTED) ) {
784 thread->sched_flags &= ~TH_SFLAG_PROMOTED;
786 if (thread->sched_flags & TH_SFLAG_RW_PROMOTED) {
788 } else if (thread->sched_flags & TH_SFLAG_DEPRESSED_MASK) {
791 thread->sched_pri, DEPRESSPRI, 0, lck, 0);
793 set_sched_pri(thread, DEPRESSPRI);
796 if (thread->priority < thread->sched_pri) {
800 thread->sched_pri, thread->priority,
804 SCHED(compute_priority)(thread, FALSE);
807 thread_unlock(thread);
910 thread_t thread = current_thread();
918 * is that this thread remains as an observer, since it may hold
920 * this situation, make sure that the thread is boosted to the
924 thread->rwlock_count++;
945 if ((thread->rwlock_count-- == 1 /* field now 0 */) && (thread->sched_flags & TH_SFLAG_RW_PROMOTED)) {
951 lck_rw_clear_promotion(thread);
972 thread_t thread = current_thread();
978 thread->rwlock_count++;
999 if ((thread->rwlock_count-- == 1 /* field now 0 */) && (thread->sched_flags & TH_SFLAG_RW_PROMOTED)) {
1005 lck_rw_clear_promotion(thread);
1033 * a per-thread counter. Only if that thread stops
1037 * When the thread becomes runnable again (or in
1048 * to the thread and independent of any particular
1054 * per-thread counter should err on the side of
1065 * lock is released by a thread (if a promotion was active)
1067 void lck_rw_clear_promotion(thread_t thread)
1069 assert(thread->rwlock_count == 0);
1071 /* Cancel any promotions if the thread had actually blocked while holding a RW lock */
1074 thread_lock(thread);
1076 if (thread->sched_flags & TH_SFLAG_RW_PROMOTED) {
1077 thread->sched_flags &= ~TH_SFLAG_RW_PROMOTED;
1079 if (thread->sched_flags & TH_SFLAG_PROMOTED) {
1081 } else if (thread->sched_flags & TH_SFLAG_DEPRESSED_MASK) {
1083 thread->sched_pri, DEPRESSPRI, 0, 0, 0);
1085 set_sched_pri(thread, DEPRESSPRI);
1088 thread->sched_pri, thread->priority, 0, 0, 0);
1090 SCHED(compute_priority)(thread, FALSE);
1094 thread_unlock(thread);