Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;

            int            sizeOfPhysicalMemory = Convert.ToInt32(numericUpDown1.Value);
            PhysicalMemory physicalMemory       = new PhysicalMemory(sizeOfPhysicalMemory);

            physicalMemory.PhysicalMemoryUpdatedEvent += OnPhysicalMemoryUpdated;

            for (int i = 0; i < sizeOfPhysicalMemory; ++i)
            {
                dataGridView1.Rows.Add();
                dataGridView1[0, i].Value = i;
                dataGridView1[1, i].Value = "Free";
            }

            int           sizeOfVirtualMemory = Convert.ToInt32(numericUpDown2.Value);
            VirtualMemory virtualMemory       = new VirtualMemory(sizeOfVirtualMemory);

            virtualMemory.VirtualMemoryUpdatedEvent += OnVirtualMemoryUpdated;

            for (int i = 0; i < sizeOfVirtualMemory; ++i)
            {
                dataGridView2.Rows.Add();
                dataGridView2[0, i].Value = "Free";
            }

            MemoryManagementUnit MMU = new MemoryManagementUnit(physicalMemory, virtualMemory);

            MMU.PageTableRequestEvent          += OnPageTableRequest;
            MMU.PageTableAnswerEvent           += OnPageTableAnswer;
            MMU.PageFaultOccuredEvent          += OnPageFaultOccured;
            MMU.PageFaultHandledEvent          += OnPageFaultHandled;
            MMU.PageAddedToPhysicalMemoryEvent += OnPageAddedToPhysicalMemory;
            MMU.PageReplacedEvent        += OnPageReplaced;
            MMU.ProcessFinishedWorkEvent += OnProcessFinishedWork;

            cpu = new CPU(Convert.ToInt32(numericUpDown3.Value), MMU);

            subThread = new Thread(Start);
            subThread.Start();
        }
Exemplo n.º 2
0
        public Process(int processID, MemoryManagementUnit MMU)
        {
            _processID = processID;
            _MMU       = MMU;

            _rnd = new Random();

            int numOfPages = _rnd.Next(2, 6);

            _pages = new Page[numOfPages];

            for (int i = 0; i < numOfPages; ++i)
            {
                _pages[i] = new Page(_processID, i);
            }

            _MMU.LoadPagesOfProcessIntoMemory(this);

            _thread = new Thread(Work);
            _thread.Start();
        }
Exemplo n.º 3
0
 public CPU(int numOfProcessesToStart, MemoryManagementUnit MMU)
 {
     _numOfProcessesToCreate = numOfProcessesToStart;
     _MMU = MMU;
 }