public void RequestMemoryPageTest()
        {
            PhysicalMemory mem = new PhysicalMemory(10);
            MemoryPage     p1  = new MemoryPage(0, 0, "Unit Test", -1);
            MemoryPage     p2  = new MemoryPage(1, 1 * MemoryPage.PAGE_SIZE, "Unit Test", -1);

            mem.AddPage(p1, 0);
            mem.AddPage(p2, 1);
            MemoryPage req = mem.RequestMemoryPage(1);

            Assert.AreEqual(p2, req);
        }
        public void AddPageTest()
        {
            PhysicalMemory mem = new PhysicalMemory(10);
            MemoryPage     m   = new MemoryPage(0, 0, "Unit Test", -1);

            mem.AddPage(m, 0);
            Assert.IsTrue(mem.Pages.Contains(m));
        }
        public void isFullTest()
        {
            PhysicalMemory m = new PhysicalMemory(10);

            for (int i = 0; i < m.Capacity; i++)
            {
                m.AddPage(new MemoryPage(0, 0, "Unit Test", -1), i);
            }
            Assert.IsTrue(m.isFull());
        }
Ejemplo n.º 4
0
        public void SwapOutTest()
        {
            PhysicalMemory mem   = new PhysicalMemory(10);
            PageTable      table = new PageTable(0);
            MemoryPage     m     = new MemoryPage(0, 0, "Unit Test", -1);

            mem.AddPage(m, 0);
            m.SwapOut(0, 0);
            Assert.IsTrue(table.Entries[0].SwappedOut);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This function allocates memory for processes
        /// </summary>
        /// <param name="proc">reference to the process to allocate memory too</param>
        public void AllocateProcessMemory(ref SimulatorProcess proc)
        {
            if (proc == null)
            {
                MessageBox.Show("Can't allocate memory for a null process");
                return;
            }
            dynamic        wind = GetMainWindowInstance();
            PhysicalMemory mem  = wind.Memory;

            for (int i = 0; i < proc.ProcessMemory; i++)
            {
                MemoryPage m = new MemoryPage(i, i * MemoryPage.PAGE_SIZE, proc.Program.Name, proc.ProcessID);
                mem.AddPage(m, i);
            }
        }