kernel: support for more than 32 total priorities
In addition to more priorities taking more memory to host them, finding the next thread to run when it is not cached is slower since each extra set of 32 priorities maps to a loop iteration. That loop is remove entirely when the number of priorities is less than 32 (31 + the idle thread). Fixes ZEP-1303. Change-Id: I3205df90d379a0f4456ff1d7f1aaa67ad2cddf15 Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
This commit is contained in:
parent
7f1c76f2bf
commit
358a53cb2f
5 changed files with 48 additions and 14 deletions
|
@ -167,17 +167,32 @@ static inline int _get_ready_q_q_index(int prio)
|
|||
return prio + CONFIG_NUM_COOP_PRIORITIES;
|
||||
}
|
||||
|
||||
#if (K_NUM_PRIORITIES > 32)
|
||||
#error not supported yet
|
||||
#endif
|
||||
|
||||
/* find out the currently highest priority where a thread is ready to run */
|
||||
/* interrupts must be locked */
|
||||
static inline int _get_highest_ready_prio(void)
|
||||
{
|
||||
uint32_t ready = _ready_q.prio_bmap[0];
|
||||
int bitmap = 0;
|
||||
uint32_t ready_range;
|
||||
|
||||
return find_lsb_set(ready) - 1 - CONFIG_NUM_COOP_PRIORITIES;
|
||||
#if (K_NUM_PRIORITIES <= 32)
|
||||
ready_range = _ready_q.prio_bmap[0];
|
||||
#else
|
||||
for (;; bitmap++) {
|
||||
|
||||
__ASSERT(bitmap < K_NUM_PRIO_BITMAPS, "prio out-of-range\n");
|
||||
|
||||
if (_ready_q.prio_bmap[bitmap]) {
|
||||
ready_range = _ready_q.prio_bmap[bitmap];
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int abs_prio = (find_lsb_set(ready_range) - 1) + (bitmap << 5);
|
||||
|
||||
__ASSERT(abs_prio < K_NUM_PRIORITIES, "prio out-of-range\n");
|
||||
|
||||
return abs_prio - CONFIG_NUM_COOP_PRIORITIES;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue