-\f
-/* Stack frame for kernel_thread(). */
-struct kernel_thread_frame
- {
- void *eip; /* Return address. */
- void (*function) (void *); /* Function to call. */
- void *aux; /* Auxiliary data for function. */
- };
-
-/* Function used as the basis for a kernel thread. */
-static void
-kernel_thread (void (*function) (void *aux), void *aux)
-{
- ASSERT (function != NULL);
-
- intr_enable (); /* The scheduler runs with interrupts off. */
- function (aux); /* Execute the thread function. */
- thread_exit (); /* If function() returns, kill the thread. */
-}
-
-/* Creates a new thread named NAME and initializes its fields.
- Returns the new thread if successful or a null pointer on
- failure. */
-static struct thread *
-new_thread (const char *name)
-{
- struct thread *t;
-
- ASSERT (name != NULL);
-
- t = palloc_get (PAL_ZERO);
- if (t != NULL)
- {
- strlcpy (t->name, name, sizeof t->name);
- t->stack = (uint8_t *) t + PGSIZE;
- t->status = THREAD_INITIALIZING;
- }
-
- return t;
-}
-
-/* Allocates a SIZE-byte frame within thread T's stack and
- returns a pointer to the frame's base. */
-static void *
-alloc_frame (struct thread *t, size_t size)
-{
- /* Stack data is always allocated in word-size units. */
- ASSERT (size % sizeof (uint32_t) == 0);
-
- t->stack -= size;
- return t->stack;
-}