//////////////////////////////////////////////////////////////////////////// // PROCESS.CC // //-The process class contains all the object need to run a single process // in its own address space. // // The process class contain: // -AddressSpace // -Count of threads still alive. // -OpenFile Table // -Join Information // -Page Table Location kept in the address space /////////////////////////////////////////////////////////////////////////// #include "process.h" #include "system.h" Lock* processLock = new Lock("processLock"); Process::processID = 0; Process::Process(OpenFile *executable, bool joinable=false) { numProcess++; processLock->Acquire(); threadCount = 1; addrSpace = new AddrSpace(executable); PID=processID; processID++; processLock->Release(); for(int i=0; i<10;i++) openFileTable[i]=NULL; } Process::~Process() { numProcess--; if(numProcess==0) interrupt->Halt(); } int Process::getThreadCount() { return threadCount; } int Process::getPID() { return PID; } void Process::incrementThreadCount() { threadCount = threadCount+1; } void Process::decrementThreadCount() { threadCount = threadCount - 1; } AddrSpace* Process::getSpace() { return addrSpace; }