def __init__(self, initialNbrOfPages): self.page_table = np.zeros(shape=(initialNbrOfPages, 1), dtype='int64') self.page_frame_vectors = [0] * initialNbrOfPages for i in range(self.page_table.shape[0]): self.page_table[i] = -1 self.available_space = initialNbrOfPages self.mypid = Process.get_pid() Memory.register_process(self)
def setx(self, page, pageFrameIndex, vectora): #change name later pls for i in range(self.page_table.shape[0]): if self.page_table[i][0] == -1: self.page_table[i][0] = pageFrameIndex self.page_frame_vectors[i] = vectora self.available_space += 1 break Memory.modify_memory(self)
def load_pages(self, listOfPages, nbrPages): listPageFrameVector = Memory.get_mem(self.mypid, nbrPages) for i in range(0, len(listOfPages)): pageFrameIndex, vectora = listPageFrameVector[i] # vectora is a pointer to memory self.setx(listOfPages[i], pageFrameIndex, vectora)
def printAll(astring, process): print(" ********* start: ", astring, '*********') process.print_mgmt() Memory.print_mem() MemoryManagement.print_management() print(" *********** end: ", astring, '***********')