Beispiel #1
0
        public void loadProcess(int pId, int textSegmentSize, int dataSegmentSize)
        {
            int numTextSegmentPages = (int)Math.Ceiling((double)textSegmentSize / pageSize);
            int numDataSegmentPages = (int)Math.Ceiling((double)dataSegmentSize / pageSize);

            //Create page tables for each segment of the process.
            PageTable textTable = new PageTable("text", numTextSegmentPages);
            PageTable dataTable = new PageTable("data", numDataSegmentPages);

            //Create an inner page to hold the two page tables.
            InnerPage innerPage;

            //Find a frame for each text segment and update the page table and the frame table.
            for (int i = 0; i < numTextSegmentPages; ++i)
            {
                for (int j = 0; j < numFrames; ++j)
                {
                    //See if frame is empty.
                    if (string.IsNullOrEmpty(frameTable[j]))
                    {
                        //Assign the page to an empty frame.
                        frameTable[j] = "P" + pId.ToString() + " Text Page " + i.ToString();
                        physicalMListRowData[j].frameInfoXAML = frameTable[j];
                        textTable.Table[i] = j;
                        break;
                    }
                }
            }

            //Find a frame for each data segment and update the page table and the frame table.
            for (int i = 0; i < numDataSegmentPages; ++i)
            {
                for (int j = 0; j < numFrames; ++j)
                {
                    //See if frame is empty.
                    if (string.IsNullOrEmpty(frameTable[j]))
                    {
                        //Assign the page to an empty frame.
                        frameTable[j] = "P" + pId.ToString() + " Data Page " + i.ToString();
                        physicalMListRowData[j].frameInfoXAML = frameTable[j];
                        dataTable.Table[i] = j;
                        break;
                    }
                }
            }

            //For GUI
            String textKey = pId.ToString() + "0";
            String dataKey = pId.ToString() + "1";

            makeRows(textKey, textTable);
            makeRows(dataKey, dataTable);
            //End for GUI

            //Create and populate the inner page.
            innerPage = new InnerPage(pId, textTable, dataTable);

            //Add the inner page to the outer page table.
            outerPageTable.Add(pId, innerPage);
        }
Beispiel #2
0
        public PCB(int pId, int textSize, int dataSize, InnerPage innerPage)
        {
            this.pId          = pId;
            this.textSize     = textSize;
            this.dataSize     = dataSize;
            this.innerPage    = innerPage;
            this.numTextPages = (int)Math.Ceiling((double)textSize / pageSize);
            this.numDataPages = (int)Math.Ceiling((double)dataSize / pageSize);

            totalNumPages = numTextPages + numDataPages;
        }