/*---------------------------------------*/
/* add to system.h */
enum ThreadState {READY, RUNNING, BLOCKED};

struct ThreadDescriptor {
  int slotAllocated;
  int timeLeft;

  /* pointers so the thread can be put on a linked list of threads */
  int nextThread, prevThread;
  int pid;  /* the process this thread runs in */
  ThreadState state; /* each thread has its own state */
  SaveArea sa; /* each thread has its own register save area */
};

struct ProcessDescriptor {
  int slotAllocated;
  int threads; /* a circular list of threads */
  /* the process is allocated an area of memory.  The base and bound
  are saved here and used to initialize the base and bound registers
  for any threads associated with this process */
  void *base, *bound;
};

/* OS GLOBAL DATA */
int current_thread; /* this is the thread that is currently running */

/* we need a process table and a thread table */
ProcessDescriptor pd[MAX_PROCESSES];
ThreadDescriptor td[MAX_THREADS];

/*---------------------------------------*/

/* Exmaple thread dispatcher */
void Dispatcher(void) {
  current_thread = SelectThreadToRun();
  RunThread(current_thread);
  /* Same throughout Select() and Run(), but use thread instead of process */
}

/*---------------------------------------*/

