mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 13:13:08 +08:00
mm/mempool: The wait variable of the memory pool is controlled by macros
The wait variable of the memory pool is modified to be controlled by macros, facilitating dynamic adjustment of its value via configuration macros. Signed-off-by: zhanxiaoqi <zhanxiaoqi@bytedance.com>
This commit is contained in:
+10
@@ -194,6 +194,16 @@ config MM_HEAP_MEMPOOL_THRESHOLD
|
||||
|
||||
if MM_HEAP_MEMPOOL_THRESHOLD > 0
|
||||
|
||||
config MM_HEAP_MEMPOOL_WAIT_RELEASE
|
||||
bool "If wait for other tasks to release memory"
|
||||
default n
|
||||
---help---
|
||||
If the macro is set to true, when the memory pool fails to allocate
|
||||
available memory, the current task will block and wait for other tasks
|
||||
to release memory. Once memory is released by other tasks, the blocked
|
||||
task will be awakened and re-attempt to allocate memory from
|
||||
the memory pool.
|
||||
|
||||
config MM_HEAP_MEMPOOL_EXPAND_SIZE
|
||||
int "The expand size for each mempool in multiple mempool"
|
||||
default 4096
|
||||
|
||||
@@ -463,8 +463,11 @@ mempool_multiple_init(FAR const char *name,
|
||||
pools[i].alloc = mempool_multiple_alloc_callback;
|
||||
pools[i].free = mempool_multiple_free_callback;
|
||||
pools[i].check = mempool_multiple_check;
|
||||
#ifdef CONFIG_MM_HEAP_MEMPOOL_WAIT_RELEASE
|
||||
pools[i].wait = true;
|
||||
#else
|
||||
pools[i].wait = false;
|
||||
|
||||
#endif
|
||||
ret = mempool_init(pools + i, name);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user