PersistentTable.hh revision 7054
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" 3412933Sgabeblack@google.com#include "mem/ruby/common/Address.hh" 3512933Sgabeblack@google.com#include "mem/ruby/common/Global.hh" 3612841Sgabeblack@google.com#include "mem/ruby/common/NetDest.hh" 3713044Sgabeblack@google.com#include "mem/ruby/system/MachineID.hh" 3812841Sgabeblack@google.com 3912841Sgabeblack@google.comclass PersistentTableEntry 4013044Sgabeblack@google.com{ 4112841Sgabeblack@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}; 4813277Sgabeblack@google.com 4913277Sgabeblack@google.comclass PersistentTable 5013277Sgabeblack@google.com{ 5113277Sgabeblack@google.com public: 5213277Sgabeblack@google.com // Constructors 5313277Sgabeblack@google.com PersistentTable(); 5413288Sgabeblack@google.com 5513277Sgabeblack@google.com // Destructor 5613277Sgabeblack@google.com ~PersistentTable(); 5712841Sgabeblack@google.com 5812841Sgabeblack@google.com // Public Methods 5913277Sgabeblack@google.com void persistentRequestLock(const Address& address, MachineID locker, 6013277Sgabeblack@google.com AccessType type); 6113277Sgabeblack@google.com void persistentRequestUnlock(const Address& address, MachineID unlocker); 6213277Sgabeblack@google.com bool okToIssueStarving(const Address& address, MachineID machID) const; 6313277Sgabeblack@google.com MachineID findSmallest(const Address& address) const; 6413277Sgabeblack@google.com AccessType typeOfSmallest(const Address& address) const; 6513277Sgabeblack@google.com void markEntries(const Address& address); 6613277Sgabeblack@google.com bool isLocked(const Address& addr) const; 6713277Sgabeblack@google.com int countStarvingForAddress(const Address& addr) const; 6813277Sgabeblack@google.com int countReadStarvingForAddress(const Address& addr) const; 6913277Sgabeblack@google.com 7013277Sgabeblack@google.com static void printConfig(ostream& out) {} 7113277Sgabeblack@google.com 7213277Sgabeblack@google.com void print(ostream& out) const; 7313277Sgabeblack@google.com 7413277Sgabeblack@google.com private: 7513277Sgabeblack@google.com // Private copy constructor and assignment operator 7613277Sgabeblack@google.com PersistentTable(const PersistentTable& obj); 7713277Sgabeblack@google.com PersistentTable& operator=(const PersistentTable& obj); 7813277Sgabeblack@google.com 7913277Sgabeblack@google.com // Data Members (m_prefix) 8013277Sgabeblack@google.com Map<Address, PersistentTableEntry>* m_map_ptr; 8113277Sgabeblack@google.com}; 8213277Sgabeblack@google.com 8313277Sgabeblack@google.cominline ostream& 8413288Sgabeblack@google.comoperator<<(ostream& out, const PersistentTable& obj) 8513288Sgabeblack@google.com{ 8613288Sgabeblack@google.com obj.print(out); 8713288Sgabeblack@google.com out << flush; 8813277Sgabeblack@google.com return out; 8913277Sgabeblack@google.com} 9013277Sgabeblack@google.com 9113277Sgabeblack@google.cominline ostream& 9213277Sgabeblack@google.comoperator<<(ostream& out, const PersistentTableEntry& obj) 9313277Sgabeblack@google.com{ 9413277Sgabeblack@google.com obj.print(out); 9513277Sgabeblack@google.com out << flush; 9613277Sgabeblack@google.com return out; 9713277Sgabeblack@google.com} 9813277Sgabeblack@google.com 9913277Sgabeblack@google.com#endif // __MEM_RUBY_SYSTEM_PERSISTENTTABLE_HH__ 10013277Sgabeblack@google.com