PersistentTable.hh revision 7039
112841Sgabeblack@google.com/* 212841Sgabeblack@google.com * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 312841Sgabeblack@google.com * All rights reserved. 412841Sgabeblack@google.com * 512841Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 612841Sgabeblack@google.com * modification, are permitted provided that the following conditions are 712841Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 812841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 912841Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1012841Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1112841Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1212841Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1312841Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1412841Sgabeblack@google.com * this software without specific prior written permission. 1512841Sgabeblack@google.com * 1612841Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712841Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812841Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912841Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012841Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112841Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212841Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312841Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412841Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512841Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612841Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712841Sgabeblack@google.com */ 2812841Sgabeblack@google.com 2912841Sgabeblack@google.com#ifndef __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3012841Sgabeblack@google.com#define __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 3112841Sgabeblack@google.com 3212841Sgabeblack@google.com#include "mem/gems_common/Map.hh" 3312841Sgabeblack@google.com#include "mem/protocol/AccessType.hh" 3413274Sgabeblack@google.com#include "mem/ruby/common/Address.hh" 3512933Sgabeblack@google.com#include "mem/ruby/common/Global.hh" 3612933Sgabeblack@google.com#include "mem/ruby/common/NetDest.hh" 3712841Sgabeblack@google.com#include "mem/ruby/system/MachineID.hh" 3813044Sgabeblack@google.com 3912841Sgabeblack@google.comclass PersistentTableEntry 4012841Sgabeblack@google.com{ 4113044Sgabeblack@google.com public: 4212841Sgabeblack@google.com void print(ostream& out) const {} 4312841Sgabeblack@google.com 4412841Sgabeblack@google.com NetDest m_starving; 4512841Sgabeblack@google.com NetDest m_marked; 4612841Sgabeblack@google.com NetDest m_request_to_write; 4712841Sgabeblack@google.com}; 4812841Sgabeblack@google.com 4912841Sgabeblack@google.comclass PersistentTable 5012841Sgabeblack@google.com{ 5112841Sgabeblack@google.com public: 5212841Sgabeblack@google.com // Constructors 5312841Sgabeblack@google.com PersistentTable(); 5412841Sgabeblack@google.com 5513044Sgabeblack@google.com // Destructor 5613274Sgabeblack@google.com ~PersistentTable(); 5713274Sgabeblack@google.com 5812841Sgabeblack@google.com // Public Methods 5913044Sgabeblack@google.com void persistentRequestLock(const Address& address, MachineID locker, 6013044Sgabeblack@google.com AccessType type); 6113274Sgabeblack@google.com void persistentRequestUnlock(const Address& address, MachineID unlocker); 6213274Sgabeblack@google.com bool okToIssueStarving(const Address& address, MachineID machID) const; 6312841Sgabeblack@google.com MachineID findSmallest(const Address& address) const; 6412912Sgabeblack@google.com AccessType typeOfSmallest(const Address& address) const; 6513044Sgabeblack@google.com void markEntries(const Address& address); 6613274Sgabeblack@google.com bool isLocked(const Address& addr) const; 6713274Sgabeblack@google.com int countStarvingForAddress(const Address& addr) const; 6813044Sgabeblack@google.com int countReadStarvingForAddress(const Address& addr) const; 6912841Sgabeblack@google.com 7012841Sgabeblack@google.com static void printConfig(ostream& out) {} 7112841Sgabeblack@google.com 7213274Sgabeblack@google.com void print(ostream& out) const; 7312841Sgabeblack@google.com 7413274Sgabeblack@google.com private: 7513274Sgabeblack@google.com // Private copy constructor and assignment operator 7613274Sgabeblack@google.com PersistentTable(const PersistentTable& obj); 7713274Sgabeblack@google.com PersistentTable& operator=(const PersistentTable& obj); 7813274Sgabeblack@google.com 7913274Sgabeblack@google.com // Data Members (m_prefix) 8013274Sgabeblack@google.com Map<Address, PersistentTableEntry>* m_map_ptr; 8113274Sgabeblack@google.com}; 8213274Sgabeblack@google.com 8313274Sgabeblack@google.cominline ostream& 8413274Sgabeblack@google.comoperator<<(ostream& out, const PersistentTable& obj) 8513274Sgabeblack@google.com{ 8613274Sgabeblack@google.com obj.print(out); 8713274Sgabeblack@google.com out << flush; 8813274Sgabeblack@google.com return out; 8913274Sgabeblack@google.com} 9013274Sgabeblack@google.com 9112841Sgabeblack@google.cominline ostream& 9212841Sgabeblack@google.comoperator<<(ostream& out, const PersistentTableEntry& obj) 9313044Sgabeblack@google.com{ 9413044Sgabeblack@google.com obj.print(out); 9512841Sgabeblack@google.com out << flush; 9612841Sgabeblack@google.com return out; 9712841Sgabeblack@google.com} 9812841Sgabeblack@google.com 9912841Sgabeblack@google.com#endif // __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 10012841Sgabeblack@google.com