int ThreadImpl::reverseMapPrio(int prio) { int pmin = getMinOSPriorityImpl(); int pmax = getMaxOSPriorityImpl(); int normal = pmin + (pmax - pmin)/2; if (prio == pmax) return PRIO_HIGHEST_IMPL; if (prio > normal) return PRIO_HIGH_IMPL; else if (prio == normal) return PRIO_NORMAL_IMPL; else if (prio > pmin) return PRIO_LOW_IMPL; else return PRIO_LOWEST_IMPL; }
int ThreadImpl::mapPrio(int prio, int policy) { int pmin = getMinOSPriorityImpl(policy); int pmax = getMaxOSPriorityImpl(policy); switch (prio) { case PRIO_LOWEST_IMPL: return pmin; case PRIO_LOW_IMPL: return pmin + (pmax - pmin)/4; case PRIO_NORMAL_IMPL: return pmin + (pmax - pmin)/2; case PRIO_HIGH_IMPL: return pmin + 3*(pmax - pmin)/4; case PRIO_HIGHEST_IMPL: return pmax; default: ; // BUG: invalid thread priority } return -1; // just to satisfy compiler - we'll never get here anyway }