-static void
-thread_root (struct thread *cur UNUSED, struct thread *next UNUSED,
- void (*function) (void *aux), void *aux)
+/* Statistics. */
+static long long idle_ticks; /* # of timer ticks spent idle. */
+static long long kernel_ticks; /* # of timer ticks in kernel threads. */
+static long long user_ticks; /* # of timer ticks in user programs. */
+
+static void kernel_thread (thread_func *, void *aux);
+
+static void idle (void *aux UNUSED);
+static struct thread *running_thread (void);
+static struct thread *next_thread_to_run (void);
+static void init_thread (struct thread *, const char *name, int priority);
+static bool is_thread (struct thread *);
+static void *alloc_frame (struct thread *, size_t size);
+static void schedule (void);
+void schedule_tail (struct thread *prev);
+static tid_t allocate_tid (void);
+
+/* Initializes the threading system by transforming the code
+ that's currently running into a thread. This can't work in
+ general and it is possible in this case only because loader.S
+ was careful to put the bottom of the stack at a page boundary.
+
+ Also initializes the run queue and the tid lock.
+
+ After calling this function, be sure to initialize the page
+ allocator before trying to create any threads with
+ thread_create(). */
+void
+thread_init (void)