diff --git a/mm/Kconfig b/mm/Kconfig index a5904dd19b2..6aa7a648031 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -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 diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c index 92ec9a1e9e9..7f31b7ef368 100644 --- a/mm/mempool/mempool_multiple.c +++ b/mm/mempool/mempool_multiple.c @@ -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) {