kernel: mem_slab: Add support to no multithreading

Mem_slab supports allocation with timeout which blocks the context
if no slab is available. Updated to treat every timeout as K_NO_WAIT
when multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
diff --git a/kernel/mem_slab.c b/kernel/mem_slab.c
index 30fa141..883a97c 100644
--- a/kernel/mem_slab.c
+++ b/kernel/mem_slab.c
@@ -121,7 +121,8 @@
 #endif
 
 		result = 0;
-	} else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT)) {
+	} else if (K_TIMEOUT_EQ(timeout, K_NO_WAIT) ||
+		   !IS_ENABLED(CONFIG_MULTITHREADING)) {
 		/* don't wait for a free block to become available */
 		*mem = NULL;
 		result = -ENOMEM;
@@ -143,7 +144,7 @@
 {
 	k_spinlock_key_t key = k_spin_lock(&slab->lock);
 
-	if (slab->free_list == NULL) {
+	if (slab->free_list == NULL && IS_ENABLED(CONFIG_MULTITHREADING)) {
 		struct k_thread *pending_thread = z_unpend_first_thread(&slab->wait_q);
 
 		if (pending_thread != NULL) {