Exemple #1
0
 public void Insert(MemoryNode memoryNode, uint unitCount)
 {
     this.Link(memoryNode);
     memoryNode.Stamp     = uint.MaxValue;
     memoryNode.UnitCount = unitCount;
     this.Stamp++;
 }
Exemple #2
0
        public MemoryNode Remove()
        {
            MemoryNode next = this.Next;

            this.Unlink();
            this.Stamp--;
            return(next);
        }
        /// <summary>
        /// Remove this memory node from the linked list.
        /// </summary>
        /// <returns></returns>
        public MemoryNode Remove()
        {
            MemoryNode next = Next;

            Unlink();
            Stamp--;
            return(next);
        }
Exemple #4
0
 public override bool Equals(object obj)
 {
     if (obj is MemoryNode)
     {
         MemoryNode node = (MemoryNode)obj;
         return(node.Address == this.Address);
     }
     return(base.Equals(obj));
 }
Exemple #5
0
 public void SpecialFreeUnits(Pointer pointer)
 {
     if (pointer != this.BaseUnit)
     {
         this.MemoryNodes[0].Insert(pointer, 1);
     }
     else
     {
         MemoryNode node = pointer;
         node.Stamp     = uint.MaxValue;
         this.BaseUnit += 12;
     }
 }
Exemple #6
0
        private void GlueFreeBlocks()
        {
            MemoryNode memoryNode = new MemoryNode(LocalOffset, Memory);
            memoryNode.Stamp = 0;
            memoryNode.Next = MemoryNode.Zero;
            memoryNode.UnitCount = 0;

            MemoryNode memoryNode0;
            MemoryNode memoryNode1;
            MemoryNode memoryNode2;

            if (LowUnit != HighUnit)
                LowUnit[0] = 0;

            // Find all unused memory nodes.

            memoryNode1 = memoryNode;
            for (uint index = 0; index < IndexCount; index++) {
                while (MemoryNodes[index].Available) {
                    memoryNode0 = MemoryNodes[index].Remove();
                    if (memoryNode0.UnitCount != 0) {
                        while ((memoryNode2 = memoryNode0 + memoryNode0.UnitCount).Stamp == uint.MaxValue) {
                            memoryNode0.UnitCount = memoryNode0.UnitCount + memoryNode2.UnitCount;
                            memoryNode2.UnitCount = 0;
                        }
                        memoryNode1.Link(memoryNode0);
                        memoryNode1 = memoryNode0;
                    }
                }
            }

            // Coalesce the memory represented by the unused memory nodes.

            while (memoryNode.Available) {
                memoryNode0 = memoryNode.Remove();
                uint unitCount = memoryNode0.UnitCount;
                if (unitCount != 0) {
                    for (; unitCount > 128; unitCount -= 128, memoryNode0 += 128)
                        MemoryNodes[IndexCount - 1].Insert(memoryNode0, 128);

                    uint index = unitsToIndex[unitCount - 1];
                    if (indexToUnits[index] != unitCount) {
                        uint unitCountDifference = unitCount - indexToUnits[--index];
                        MemoryNodes[unitCountDifference - 1].Insert(memoryNode0 + (unitCount - unitCountDifference),
                                                                    unitCountDifference);
                    }

                    MemoryNodes[index].Insert(memoryNode0, indexToUnits[index]);
                }
            }

            GlueCount = 1 << 13;
        }
Exemple #7
0
        private void GlueFreeBlocks()
        {
            MemoryNode memoryNode = new MemoryNode(LocalOffset, Memory);

            memoryNode.Stamp     = 0;
            memoryNode.Next      = MemoryNode.Zero;
            memoryNode.UnitCount = 0;

            MemoryNode memoryNode0;
            MemoryNode memoryNode1;
            MemoryNode memoryNode2;

            if (LowUnit != HighUnit)
            {
                LowUnit[0] = 0;
            }

            // Find all unused memory nodes.

            memoryNode1 = memoryNode;
            for (uint index = 0; index < IndexCount; index++)
            {
                while (MemoryNodes[index].Available)
                {
                    memoryNode0 = MemoryNodes[index].Remove();
                    if (memoryNode0.UnitCount != 0)
                    {
                        while ((memoryNode2 = memoryNode0 + memoryNode0.UnitCount).Stamp == uint.MaxValue)
                        {
                            memoryNode0.UnitCount = memoryNode0.UnitCount + memoryNode2.UnitCount;
                            memoryNode2.UnitCount = 0;
                        }
                        memoryNode1.Link(memoryNode0);
                        memoryNode1 = memoryNode0;
                    }
                }
            }

            // Coalesce the memory represented by the unused memory nodes.

            while (memoryNode.Available)
            {
                memoryNode0 = memoryNode.Remove();
                uint unitCount = memoryNode0.UnitCount;
                if (unitCount != 0)
                {
                    for (; unitCount > 128; unitCount -= 128, memoryNode0 += 128)
                    {
                        MemoryNodes[IndexCount - 1].Insert(memoryNode0, 128);
                    }

                    uint index = unitsToIndex[unitCount - 1];
                    if (indexToUnits[index] != unitCount)
                    {
                        uint unitCountDifference = unitCount - indexToUnits[--index];
                        MemoryNodes[unitCountDifference - 1].Insert(memoryNode0 + (unitCount - unitCountDifference),
                                                                    unitCountDifference);
                    }

                    MemoryNodes[index].Insert(memoryNode0, indexToUnits[index]);
                }
            }

            GlueCount = 1 << 13;
        }
 /// <summary>
 /// Link in the provided memory node.
 /// </summary>
 /// <param name="memoryNode"></param>
 public void Link(MemoryNode memoryNode)
 {
     memoryNode.Next = Next;
     Next = memoryNode;
 }
 /// <summary>
 /// Insert the memory node into the linked list.
 /// </summary>
 /// <param name="memoryNode"></param>
 /// <param name="unitCount"></param>
 public void Insert(MemoryNode memoryNode, uint unitCount)
 {
     Link(memoryNode);
     memoryNode.Stamp = uint.MaxValue;
     memoryNode.UnitCount = unitCount;
     Stamp++;
 }
Exemple #10
0
 public void Link(MemoryNode memoryNode)
 {
     memoryNode.Next = this.Next;
     this.Next       = memoryNode;
 }
Exemple #11
0
 static MemoryNode()
 {
     Zero = new MemoryNode(0, null);
 }
Exemple #12
0
 /// <summary>
 /// Link in the provided memory node.
 /// </summary>
 /// <param name="memoryNode"></param>
 public void Link(MemoryNode memoryNode)
 {
     memoryNode.Next = Next;
     Next            = memoryNode;
 }
Exemple #13
0
 static MemoryNode()
 {
     Zero = new MemoryNode(0, null);
 }
Exemple #14
0
 public void Link(MemoryNode memoryNode)
 {
     memoryNode.Next = this.Next;
     this.Next = memoryNode;
 }