Exemplo n.º 1
0
        public ProcessContextBlock()
        {
            Registers = new uint[10];
            Locks = new HashSet<Lock>();

            Stack = new PageInfo();
            Code = new PageInfo();
            GlobalData = new PageInfo();

            PageTable = new PageTable {Code, GlobalData, Stack};
        }
Exemplo n.º 2
0
        public void Write()
        {
            var buffer = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            const uint frameSize = 4;
            var ram = new Ram(buffer, frameSize);
            var pageSet = new PageInfo();

            var pcb = new ProcessContextBlock {Id = 1};
            ram.Allocate(pcb);
            pageSet.Append(ram.Allocate(pcb));
            pageSet.Append(ram.Allocate(pcb));

            var pageStream = new PageStream(ram, pageSet);
            Assert.That(pageStream.Length, Is.EqualTo(8));

            var b = new byte[] { 91, 92, 93, 94, };
            pageStream.Position = 2;
            pageStream.Write(b, 0, 4);

            Assert.That(buffer, Is.EquivalentTo(new[] { 1, 2, 3, 4, 5, 6, 91, 92, 93, 94, 11, 12, }));
        }
Exemplo n.º 3
0
        public void Read()
        {
            var buffer = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            const uint frameSize = 4;
            var ram = new Ram(buffer, frameSize);
            var pageSet = new PageInfo();

            var pcb = new ProcessContextBlock {Id = 1};
            ram.Allocate(pcb);
            pageSet.Append(ram.Allocate(pcb));
            pageSet.Append(ram.Allocate(pcb));

            var pageStream = new PageStream(ram, pageSet);
            Assert.That(pageStream.Length, Is.EqualTo(8));

            var b = new byte[6];
            pageStream.Read(b, 0, 6);

            Assert.That(pageStream.Position, Is.EqualTo(6));

            Assert.That(b, Is.EquivalentTo(new[] { 5, 6, 7, 8, 9, 10 }));
        }