Пример #1
0
        public void CreateShared()
        {
            var ram = new Ram(1024, 256);
            var offset = ram.AllocateShared(512);
            Assert.That(offset, Is.EqualTo(0));

            var pcb = new ProcessContextBlock {Id = 10};
            var p1 = ram.Allocate(pcb);
            var p2 = ram.Allocate(pcb);

            var p1Offset = ram.ToPhysicalAddress(10, p1.VirtualAddress);
            var p2Offset = ram.ToPhysicalAddress(10, p2.VirtualAddress);
            Assert.That(p1Offset, Is.GreaterThan(offset));
            Assert.That(p2Offset, Is.GreaterThan(offset));
            Assert.That(p2Offset, Is.GreaterThan(p1Offset));
        }
Пример #2
0
        public void SetUp()
        {
            const uint pId = 10;

            var ram = new Ram(_ram, 16);
            _sharedOffset  = (int) ram.AllocateShared(256);

            _cpu = new Cpu(ram);
            _cpu.InputDevice = new InputDevice();

            var p = CreateProcess(pId);
            _cpu.CurrentProcess = p;
            _cpu.CurrentProcess.Registers[Register.H] = p.GlobalData.Offset;

            var heap = _cpu.Ram.Allocate(_cpu.IdleProcess);
            _heapOffset = (int) _cpu.Ram.ToPhysicalAddress(_cpu.IdleProcess.Id, heap.VirtualAddress);
            _cpu.Ram.Free(heap);
        }