void updateGui(int _pid, Process p) { DataGridView dgv = this.dgvList[_pid - 1]; List <VirtualFrame> vfl = p.getFrameList(); List <PageTableEntry> ptel = p.getPageTable().getEntryList(); List <PhysicalFrame> pfl = this.pm.getFrameList(); //virtual memory for (int x = 0; x < LOGICAL_ADDR_SPACE; x++) { VirtualFrame vf = vfl[x]; if (vf.isReferenced()) { dgv.Rows[x].Cells[1].Value = "Yes"; dgv.Rows[x].Cells[1].Style.BackColor = Color.Gray; } } this.pageDataGridView.Rows.Clear(); //page table int y = 0; foreach (PageTableEntry pte in ptel) { string frame = pte.getFrame().ToString(); string valid = "Y"; string resident = "Y"; string secondary = pte.getSecondary().ToString(); if (pte.getFrame() == -1) { frame = ""; } if (pte.getSecondary() == -1) { secondary = ""; } if (!pte.isValid()) { valid = "N"; } if (y < 16) { if (!pte.isResident()) { resident = "N"; } } else { resident = "-"; } this.pageDataGridView.Rows.Add(frame, valid, resident, secondary); y++; } this.pageGroupBox.Text = "Page Table (P" + _pid + ")"; //physical memory for (int x = 0; x < PHY_MEM_SIZE; x++) { if (!pfl[x].isEmpty()) { PageTableEntry pteInMem = pfl[x].getEntry(); int framePID = pteInMem.getOwnerPID(); int pageTableFrame = pteInMem.getFrame(); this.phyDataGridView.Rows[x].Cells[1].Value = "Frame: " + pageTableFrame; this.phyDataGridView.Rows[x].Cells[1].Style.BackColor = getColorForPID(framePID); } } }
void updateGui(int _pid) { this.pageFaultLabel.Text = "Page faults: " + pm.getFaultCounter() + " (P1: " + processList[1].getPageFaultCounter() + " |" + " P2: " + processList[2].getPageFaultCounter() + " |" + " P3: " + processList[3].getPageFaultCounter() + " |" + " P4: " + processList[4].getPageFaultCounter() + " |" + " P5: " + processList[5].getPageFaultCounter() + ")"; //update the VM data grid views for (int z = 0; z < PROCESS_NUM; z++) { DataGridView dgv = this.dgvList[z]; for (int x = 0; x < LOGICAL_ADDR_SPACE; x++) { List <VirtualFrame> vfl = processList[z + 1].getFrameList(); VirtualFrame vf = vfl[x]; if (vf.isReferenced()) { dgv.Rows[x].Cells[1].Value = "Yes"; dgv.Rows[x].Cells[1].Style.BackColor = Color.Gray; } } } //update each page table data grid view int y = 0; foreach (DataGridView dgv in this.pageDVGList) { List <PageTableEntry> ptel = this.processList[y + 1].getPageTable().getEntryList(); int ptIndex = 0; foreach (PageTableEntry pte in ptel) { string frame = pte.getFrame().ToString(); string valid = "Y"; string resident = "Y"; if (pte.getFrame() == -1) { frame = ""; valid = ""; resident = ""; } else { if (!pte.isValid()) { valid = "N"; } if (!pte.isResident()) { resident = "N"; } dgv[0, ptIndex].Value = frame; dgv[1, ptIndex].Value = valid; dgv[2, ptIndex].Value = resident; } ptIndex++; } y++; } //update physical memory data grid view List <PhysicalFrame> pfl = this.pm.getFrameList(); for (int x = 0; x < PHY_MEM_SIZE; x++) { if (!pfl[x].isEmpty()) { PageTableEntry pteInMem = pfl[x].getEntry(); int framePID = pteInMem.getOwnerPID(); int pageTableFrame = pteInMem.getFrame(); this.phyDataGridView.Rows[x].Cells[1].Value = pteInMem.getLastModified().ToString(); this.phyDataGridView.Rows[x].Cells[1].Style.BackColor = getColorForPID(framePID); } } }