From 0c6c70a6127008cca69ff7d8e7d2c05d1e75feb7 Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Thu, 21 Nov 2013 12:17:11 +0100 Subject: [PATCH] cpu_session: follow-up fix for scale_priority This is a fixup for commit 5a42f40f04981581327639a75298e9e653ef39f5. ref #961 --- base/include/cpu_session/cpu_session.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/base/include/cpu_session/cpu_session.h b/base/include/cpu_session/cpu_session.h index fcc2514dce..c6f3e807b6 100644 --- a/base/include/cpu_session/cpu_session.h +++ b/base/include/cpu_session/cpu_session.h @@ -199,12 +199,21 @@ namespace Genode { * be power of 2 * \param prio generic priority value as used by the CPU * session interface + * \param inverse order of platform priorities, if true + * 'pf_prio_limit' corresponds to the highest + * priority, otherwise it refers to the + * lowest priority. * \return platform-specific priority value */ - static unsigned scale_priority(unsigned pf_prio_limit, unsigned prio) + static unsigned scale_priority(unsigned pf_prio_limit, unsigned prio, + bool inverse = true) { - /* if no priorities are used, use the platform priority limit */ - if (prio == 0) return pf_prio_limit; + /* + * Generic priority values are (0 is highest, 'PRIORITY_LIMIT' + * is lowest. On platforms where priority levels are defined + * the other way round, we have to invert the priority value. + */ + prio = inverse ? Cpu_session::PRIORITY_LIMIT - prio : prio; /* scale value to platform priority range 0..pf_prio_limit */ return (prio*pf_prio_limit)/Cpu_session::PRIORITY_LIMIT;