hw4 test
This commit is contained in:
@@ -80,6 +80,10 @@ class Thread {
|
||||
int *stackTop; // the current stack pointer
|
||||
void *machineState[MachineStateSize]; // all registers except for stackTop
|
||||
|
||||
// Todo ----
|
||||
int priority;
|
||||
// ---------
|
||||
|
||||
public:
|
||||
Thread(char* debugName, int threadID); // initialize a Thread
|
||||
~Thread(); // deallocate a Thread
|
||||
@@ -89,6 +93,11 @@ class Thread {
|
||||
|
||||
// basic thread operations
|
||||
|
||||
// Todo ----
|
||||
int getPriority() const;
|
||||
void setPriority(int p);
|
||||
// ---------
|
||||
|
||||
void Fork(VoidFunctionPtr func, void *arg);
|
||||
// Make thread run (*func)(arg)
|
||||
void Yield(); // Relinquish the CPU if any
|
||||
@@ -97,32 +106,32 @@ class Thread {
|
||||
// relinquish the processor
|
||||
void Begin(); // Startup code for the thread
|
||||
void Finish(); // The thread is done executing
|
||||
|
||||
|
||||
void CheckOverflow(); // Check if thread stack has overflowed
|
||||
void setStatus(ThreadStatus st) { status = st; }
|
||||
ThreadStatus getStatus() { return (status); }
|
||||
char* getName() { return (name); }
|
||||
|
||||
int getID() { return (ID); }
|
||||
char* getName() { return (name); }
|
||||
|
||||
int getID() { return (ID); }
|
||||
void Print() { cout << name; }
|
||||
void SelfTest(); // test whether thread impl is working
|
||||
|
||||
private:
|
||||
// some of the private data for this class is listed above
|
||||
|
||||
|
||||
int *stack; // Bottom of the stack
|
||||
// NULL if this is the main thread
|
||||
// (If NULL, don't deallocate stack)
|
||||
// NULL if this is the main thread
|
||||
// (If NULL, don't deallocate stack)
|
||||
ThreadStatus status; // ready, running or blocked
|
||||
char* name;
|
||||
int ID;
|
||||
int ID;
|
||||
void StackAllocate(VoidFunctionPtr func, void *arg);
|
||||
// Allocate a stack for thread.
|
||||
// Used internally by Fork()
|
||||
// Allocate a stack for thread.
|
||||
// Used internally by Fork()
|
||||
|
||||
// A thread running a user program actually has *two* sets of CPU registers --
|
||||
// one for its state while executing user code, one for its state
|
||||
// while executing kernel code.
|
||||
// A thread running a user program actually has *two* sets of CPU registers --
|
||||
// one for its state while executing user code, one for its state
|
||||
// while executing kernel code.
|
||||
|
||||
int userRegisters[NumTotalRegs]; // user-level CPU register state
|
||||
|
||||
|
||||
Reference in New Issue
Block a user