kernel: fix total number of coop prios in coop-only mode

The idle priority was not accounted for.

With this change, the philosophers demo runs in coop-only mode.

Change-Id: I23db33687bcf3b2107d5fc07977143730f62e476
Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
This commit is contained in:
Benjamin Walsh 2017-01-14 19:23:46 -05:00 committed by Anas Nashif
parent 4bfa0055b7
commit 2f280416e6
3 changed files with 19 additions and 6 deletions

View file

@ -53,7 +53,20 @@ extern "C" {
#define K_DEBUG(fmt, ...)
#endif
#define K_PRIO_COOP(x) (-(CONFIG_NUM_COOP_PRIORITIES - (x)))
#if defined(CONFIG_COOP_ENABLED) && defined(CONFIG_PREEMPT_ENABLED)
#define _NUM_COOP_PRIO (CONFIG_NUM_COOP_PRIORITIES)
#define _NUM_PREEMPT_PRIO (CONFIG_NUM_PREEMPT_PRIORITIES + 1)
#elif defined(CONFIG_COOP_ENABLED)
#define _NUM_COOP_PRIO (CONFIG_NUM_COOP_PRIORITIES + 1)
#define _NUM_PREEMPT_PRIO (0)
#elif defined(CONFIG_PREEMPT_ENABLED)
#define _NUM_COOP_PRIO (0)
#define _NUM_PREEMPT_PRIO (CONFIG_NUM_PREEMPT_PRIORITIES + 1)
#else
#error "invalid configuration"
#endif
#define K_PRIO_COOP(x) (-(_NUM_COOP_PRIO - (x)))
#define K_PRIO_PREEMPT(x) (x)
#define K_ANY NULL

View file

@ -181,19 +181,19 @@ static inline int _get_new_prio_with_ceiling(int prio)
/* find out the prio bitmap index for a given prio */
static inline int _get_ready_q_prio_bmap_index(int prio)
{
return (prio + CONFIG_NUM_COOP_PRIORITIES) >> 5;
return (prio + _NUM_COOP_PRIO) >> 5;
}
/* find out the prio bit for a given prio */
static inline int _get_ready_q_prio_bit(int prio)
{
return (1 << ((prio + CONFIG_NUM_COOP_PRIORITIES) & 0x1f));
return (1 << ((prio + _NUM_COOP_PRIO) & 0x1f));
}
/* find out the ready queue array index for a given prio */
static inline int _get_ready_q_q_index(int prio)
{
return prio + CONFIG_NUM_COOP_PRIORITIES;
return prio + _NUM_COOP_PRIO;
}
/* find out the currently highest priority where a thread is ready to run */
@ -221,7 +221,7 @@ static inline int _get_highest_ready_prio(void)
__ASSERT(abs_prio < K_NUM_PRIORITIES, "prio out-of-range\n");
return abs_prio - CONFIG_NUM_COOP_PRIORITIES;
return abs_prio - _NUM_COOP_PRIO;
}
/*

View file

@ -374,7 +374,7 @@ void _dump_ready_q(void)
K_DEBUG("\n");
for (int prio = 0; prio < K_NUM_PRIORITIES; prio++) {
K_DEBUG("prio: %d, head: %p\n",
prio - CONFIG_NUM_COOP_PRIORITIES,
prio - _NUM_COOP_PRIO,
sys_dlist_peek_head(&_ready_q.q[prio]));
}
}