#ifndef HEADER_THREAD_H
#define HEADER_THREAD_H 1
+#include <debug.h>
+#include <list.h>
#include <stdint.h>
-#include "debug.h"
-#include "list.h"
#ifdef USERPROG
-#include "addrspace.h"
+#include "userprog/addrspace.h"
#endif
/* States in a thread's life cycle. */
the `magic' member of the running thread's `struct thread' is
set to THREAD_MAGIC. Stack overflow will normally change this
value, triggering the assertion. */
+/* The `elem' member has a dual purpose. It can be an element in
+ the run queue (thread.c), or it can be an element in a
+ semaphore wait list (synch.c). It can be used these two ways
+ only because they are mutually exclusive: only a thread in the
+ ready state is on the run queue, whereas only a thread in the
+ blocked state is on a semaphore wait list. */
struct thread
{
/* These members are owned by the thread_*() functions. */
enum thread_status status; /* Thread state. */
char name[16]; /* Name (for debugging purposes). */
uint8_t *stack; /* Saved stack pointer. */
- list_elem rq_elem; /* Run queue list element. */
+ list_elem elem; /* List element. */
#ifdef USERPROG
/* These members are owned by the addrspace_*() functions. */