+
+#if CONFIG_KERN_HEAP
+
+/**
+ * Free all the resources of all zombie processes previously added to the zombie
+ * list.
+ */
+static void proc_freeZombies(void)
+{
+ Process *proc;
+
+ while (1)
+ {
+ PROC_ATOMIC(proc = (Process *)list_remHead(&zombie_list));
+ if (proc == NULL)
+ return;
+
+ if (proc->flags & PF_FREESTACK)
+ {
+ PROC_ATOMIC(heap_freemem(&proc_heap, proc->stack_base,
+ proc->stack_size + PROC_SIZE_WORDS * sizeof(cpu_stack_t)));
+ }
+ }
+}
+
+/**
+ * Enqueue a process in the zombie list.
+ */
+static void proc_addZombie(Process *proc)
+{
+ Node *node;
+#if CONFIG_KERN_PREEMPT
+ ASSERT(!proc_preemptAllowed());
+#endif
+
+#if CONFIG_KERN_PRI
+ node = &(proc)->link.link;
+#else
+ node = &(proc)->link;
+#endif
+ LIST_ASSERT_VALID(&zombie_list);
+ ADDTAIL(&zombie_list, node);
+}
+
+#endif /* CONFIG_KERN_HEAP */
+