kernel: dynamic: Fix stack allocation logic
Fix the preference allocation logic. If pool is preferred but POOL_SIZE is 0 or pool allocation fails, it fallbacks to heap allocation if it is enabled. Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
parent
3b7e0b672e
commit
4feb182f12
|
@ -88,14 +88,14 @@ k_thread_stack_t *z_impl_k_thread_stack_alloc(size_t size, int flags)
|
|||
if (stack == NULL && CONFIG_DYNAMIC_THREAD_POOL_SIZE > 0) {
|
||||
stack = z_thread_stack_alloc_pool(size);
|
||||
}
|
||||
} else if (IS_ENABLED(CONFIG_DYNAMIC_THREAD_PREFER_POOL) &&
|
||||
CONFIG_DYNAMIC_THREAD_POOL_SIZE > 0) {
|
||||
stack = z_thread_stack_alloc_pool(size);
|
||||
if (stack == NULL && IS_ENABLED(CONFIG_DYNAMIC_THREAD_ALLOC)) {
|
||||
} else if (IS_ENABLED(CONFIG_DYNAMIC_THREAD_PREFER_POOL)) {
|
||||
if (CONFIG_DYNAMIC_THREAD_POOL_SIZE > 0) {
|
||||
stack = z_thread_stack_alloc_pool(size);
|
||||
}
|
||||
|
||||
if ((stack == NULL) && IS_ENABLED(CONFIG_DYNAMIC_THREAD_ALLOC)) {
|
||||
stack = stack_alloc_dyn(size, flags);
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
|
Loading…
Reference in New Issue