//returns the last time the page in the frame was referenced
 public int getStepLastReferenced()
 {
     if (pte == null)
     {
         return(0);
     }
     else
     {
         return(pte.getLastModified());
     }
 }
Exemple #2
0
        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);
                }
            }
        }