Example #1
0
File: TLB.cs Project: claassen/RIVM
        public void AddEntry(int vpn, int pfn)
        {
            bool success = false;

            for (int i = 0; i < _entries.Length; i++)
            {
                if (_entries[i] == null || !_entries[i].Valid)
                {
                    success = true;
                    _entries[i] = new TLBEntry()
                    {
                        Valid = true,
                        VPN = vpn,
                        PFN = pfn
                    };
                }
            }

            while (!success)
            {
                //Eject a random entry (only if it's not marked as permanent)
                int index = new Random().Next(_entries.Length);

                if (!_entries[index].Permanent)
                {
                    _entries[index] = new TLBEntry()
                    {
                        Valid = true,
                        VPN = vpn,
                        PFN = pfn
                    };

                    success = true;
                }
            }
        }
Example #2
0
File: TLB.cs Project: claassen/RIVM
        public void AddEntry(int vpn, int pfn)
        {
            bool success = false;

            for (int i = 0; i < _entries.Length; i++)
            {
                if (_entries[i] == null || !_entries[i].Valid)
                {
                    success     = true;
                    _entries[i] = new TLBEntry()
                    {
                        Valid = true,
                        VPN   = vpn,
                        PFN   = pfn
                    };
                }
            }

            while (!success)
            {
                //Eject a random entry (only if it's not marked as permanent)
                int index = new Random().Next(_entries.Length);

                if (!_entries[index].Permanent)
                {
                    _entries[index] = new TLBEntry()
                    {
                        Valid = true,
                        VPN   = vpn,
                        PFN   = pfn
                    };

                    success = true;
                }
            }
        }