+/* Invoke function 'func' on all threads, passing along 'aux'.
+ This function must be called with interrupts off. */
+void
+thread_foreach (thread_action_func *func, void *aux)
+{
+ struct list_elem *e;
+
+ ASSERT (intr_get_level () == INTR_OFF);
+
+ for (e = list_begin (&all_list); e != list_end (&all_list);
+ e = list_next (e))
+ {
+ struct thread *t = list_entry (e, struct thread, allelem);
+ func (t, aux);
+ }
+}
+