42 #include "copyright.h" 53 #define MachineStateSize 18 58 #define StackSize (4 * 1024) // in words 63 { JUST_CREATED, RUNNING, READY, BLOCKED };
90 Thread (
const char *debugName);
98 void Fork (VoidFunctionPtr func,
int arg);
108 const char *getName ()
114 printf (
"%s, ", name);
117 void setUserThread(
void * userThreadAdress);
118 void * getUserThreadAdress();
125 bool stopped =
false;
126 bool inAMutex =
false;
137 void StackAllocate (VoidFunctionPtr func,
int arg);
147 int userRegisters[NumTotalRegs];
150 void SaveUserState ();
151 void RestoreUserState ();
void Yield()
Thread::Yield Relinquish the CPU if any other thread is ready to run. If so, put the thread on the en...
Definition: thread.cc:203
Data structures to keep track of executing user programs.
void ThreadPrint(int arg)
external function, dummy routine whose sole job is to call Thread::Print
Definition: thread.cc:336
void Sleep()
Thread::Sleep Relinquish the CPU, because the current thread is blocked waiting on a synchronization ...
Definition: thread.cc:246
The following class defines a "thread control block" – which represents a single thread of execution...
Definition: thread.h:79
Definition: addrspace.h:24
void CheckOverflow()
Thread::CheckOverflow Check a thread's stack to see if it has overrun the space that has been allocat...
Definition: thread.cc:140
void enterCritiqueExt()
Thread::enterCritiqueExt From exterior of a thread Get a semaphore for "critic area" code with still ...
Definition: thread.cc:503
#define MachineStateSize
CPU register state to be saved on context switch. The SPARC and MIPS only need 10 registers...
Definition: thread.h:53
ThreadStatus
Thread state.
Definition: thread.h:62
void enterCritique()
Thread::enterCritique Get a semaphore for "critic area" code with still having interrupt.
Definition: thread.cc:492
void setStatus(ThreadStatus st)
Thread::setStatus Set the status as in parameter with debug info.
Definition: thread.cc:479
void exitCritique()
Thread::exitCritique Drop the semaphore for the critique zone of code, see Thread::enterCritique.
Definition: thread.cc:512
Miscellaneous useful definitions, including debugging routines.
~Thread()
Thread::~Thread De-allocate a thread.
Definition: thread.cc:67
void Fork(VoidFunctionPtr func, int arg)
Thread::Fork Invoke (*func)(arg), allowing caller and callee to execute concurrently.
Definition: thread.cc:99
Data structures for synchronizing threads.
Data structures for simulating the execution of user programs running on top of Nachos.
void Finish()
Thread::Finish Called by ThreadRoot when a thread is done executing the forked procedure.
Definition: thread.cc:167
Thread(const char *debugName)
Thread::Thread Initialize a thread control block, so that we can then call Thread::Fork.
Definition: thread.cc:37