Quy Trinh Lam Do An 2
Quy Trinh Lam Do An 2
Quy Trinh Lam Do An 2
h + BitMap *gPhysPageBitMap; gPhysPageBitMap = new BitMap(256); va delete gPhysPageBitMap; vao nachos/threads/system.cc + AddrSpace(char *filename); void LoadSegment(OpenFile *executable, int addr, int size, int inFileAddr) ; ExceptionType Translate(int virtAddr, int * phyAddr, int size); void freeFrames(); vao userprog/addrspace.h + Chinh sua ham AddrSpace::AddrSpace(OpenFile *executable) va viet cac x u ly cho AddrSpace(char *filename); void LoadSegment(OpenFile *executable, int addr, int size, int i nFileAddr) ; ExceptionType Translate(int virtAddr, int * phyAddr, int size); void freeFrames(); trong userprog/addrspace.h 3. Cai dat SpaceID Exec(char* name, int priority) + Trong /code/userprog/syscall.h them SpaceID Exec(char* name, int priority) + Trong exception lap trinh xu ly cho truong hop SC_Exec
2. Them cac lop + "ptable.h"; "stable.h"; "ptable.cc"; "stable.cc"; "pcb.h"; "pcb.cc" va o code/threads + Them ../threads/ptable.h ../threads/stable.h ../threads/pcb.h vao cuoi doan USERPROG_H = trong nachos/code/Makefile.common va cuoi doan USERPROG_C = .. them vao ../threads/ptable.cc va cuoi doan USERPROG_O = .. them vao ptable.o ............................................................ + Them vao nachos/threads/system.h #include "bitmap.h" #include "ptable.h" #include "stable.h" #include "pcb.h" extern BitMap *gPhysPageBitMap; extern Semaphore *addrLock; extern PTable *pTab; extern STable *lockTab; + Them vao nachos/threads/system.cc BitMap *gPhysPageBitMap; Semaphore* addrLock; PTable *pTab; STable *lockTab; gPhysPageBitMap = new BitMap(256); addrLock = new Semaphore("addrLock",1); pTab = new PTable(10); lockTab = new STable(); delete addrLock; delete gPhysPageBitMap;
delete pTab; delete lockTab; Them vao phan public trong code/threads/thread.h int processID; // iD cua thread int exitStatus; // //Thread(char* debugName, int _priority);// initialize a Thread with priority void FreeSpace() { if(space != NULL) delete space; } int getPriority() { return priority ; } //return assigned prior ity void setPriority(int priorityNumber) { priority = priorityNumber ; } //set thread's priority void RollBackPriority(){priority = old_priority;} unsigned int GetTime_RDL(){ return time_into_RDL;} void SetTime_RDL(unsigned int _time_into_RDL ){time_into_RDL = _ time_into_RDL;} Them vao phan private trong code/threads/thread.h int priority; int old_priority; unsigned int time_into_RDL;