This repository has been archived on 2026-04-18. You can view files and clone it, but cannot push or open issues or pull requests.
Virtual-Memory-Demo/Assets/Scripts/Simulation/PageTableEntry.cs

37 lines
901 B
C#

using System;
namespace VMdemo.Simulation
{
[Serializable]
public readonly struct PageTableEntry
{
public PageTableEntry(ulong pfn, bool present, bool dirty = false)
{
Pfn = pfn;
Present = present;
Dirty = dirty;
}
public ulong Pfn { get; }
public bool Present { get; }
public bool Dirty { get; }
public static PageTableEntry NotPresent => new PageTableEntry(0UL, false, false);
public PageTableEntry MarkPresent(ulong pfn, bool dirty = false)
{
return new PageTableEntry(pfn, true, dirty);
}
public PageTableEntry MarkNotPresent()
{
return new PageTableEntry(Pfn, false, Dirty);
}
public override string ToString()
{
return $"PFN={Pfn}, Present={Present}, Dirty={Dirty}";
}
}
}