-void
-assert_thread_sched_count(thread_t thread) {
- /* Only 0 or 1 are acceptable values */
- assert(thread->BG_COUNT == 0 || thread->BG_COUNT == 1);
- assert(thread->SHARE_COUNT == 0 || thread->SHARE_COUNT == 1);
-
- /* BG is only allowed when you already have a share count */
- if (thread->BG_COUNT == 1)
- assert(thread->SHARE_COUNT == 1);
- if (thread->SHARE_COUNT == 0)
- assert(thread->BG_COUNT == 0);
-
- if ((thread->state & (TH_RUN|TH_IDLE)) != TH_RUN ||
- (thread->sched_mode != TH_MODE_TIMESHARE))
- assert(thread->SHARE_COUNT == 0);
-
- if ((thread->state & (TH_RUN|TH_IDLE)) == TH_RUN &&
- (thread->sched_mode == TH_MODE_TIMESHARE))
- assert(thread->SHARE_COUNT == 1);
-
- if ((thread->state & (TH_RUN|TH_IDLE)) != TH_RUN ||
- (thread->sched_mode != TH_MODE_TIMESHARE) ||
- !(thread->sched_flags & TH_SFLAG_THROTTLED))
- assert(thread->BG_COUNT == 0);
-
- if ((thread->state & (TH_RUN|TH_IDLE)) == TH_RUN &&
- (thread->sched_mode == TH_MODE_TIMESHARE) &&
- (thread->sched_flags & TH_SFLAG_THROTTLED))
- assert(thread->BG_COUNT == 1);