diff --git a/include/kernel.h b/include/kernel.h index 7edb398d40f..c5764b14730 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -4841,7 +4841,7 @@ extern int k_mem_slab_init(struct k_mem_slab *slab, void *buffer, * This routine allocates a memory block from a memory slab. * * @note @a timeout must be set to K_NO_WAIT if called from ISR. - * @note When CONFIG_MULTITHREADING=n any @timeout is treated as K_NO_WAIT. + * @note When CONFIG_MULTITHREADING=n any @a timeout is treated as K_NO_WAIT. * * @funcprops \isr_ok * @@ -4962,6 +4962,7 @@ void k_heap_init(struct k_heap *h, void *mem, size_t bytes); * k_heap_free(). * * @note @a timeout must be set to K_NO_WAIT if called from ISR. + * @note When CONFIG_MULTITHREADING=n any @a timeout is treated as K_NO_WAIT. * * @funcprops \isr_ok * @@ -4985,6 +4986,7 @@ void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes, * the timeout, NULL will be returned. * * @note @a timeout must be set to K_NO_WAIT if called from ISR. + * @note When CONFIG_MULTITHREADING=n any @a timeout is treated as K_NO_WAIT. * * @funcprops \isr_ok * diff --git a/kernel/kheap.c b/kernel/kheap.c index a3217dd30af..7683d050702 100644 --- a/kernel/kheap.c +++ b/kernel/kheap.c @@ -39,7 +39,8 @@ void *k_heap_aligned_alloc(struct k_heap *h, size_t align, size_t bytes, ret = sys_heap_aligned_alloc(&h->heap, align, bytes); now = sys_clock_tick_get(); - if ((ret != NULL) || ((end - now) <= 0)) { + if (!IS_ENABLED(CONFIG_MULTITHREADING) || + (ret != NULL) || ((end - now) <= 0)) { break; } @@ -58,7 +59,7 @@ void k_heap_free(struct k_heap *h, void *mem) sys_heap_free(&h->heap, mem); - if (z_unpend_all(&h->wait_q) != 0) { + if (IS_ENABLED(CONFIG_MULTITHREADING) && z_unpend_all(&h->wait_q) != 0) { z_reschedule(&h->lock, key); } else { k_spin_unlock(&h->lock, key);