19171Snilay@cs.wisc.edu/* 29171Snilay@cs.wisc.edu * Copyright (c) 2012 Mark D. Hill and David A. Wood 39171Snilay@cs.wisc.edu * All rights reserved. 49171Snilay@cs.wisc.edu * 59171Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without 69171Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are 79171Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright 89171Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer; 99171Snilay@cs.wisc.edu * redistributions in binary form must reproduce the above copyright 109171Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer in the 119171Snilay@cs.wisc.edu * documentation and/or other materials provided with the distribution; 129171Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its 139171Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from 149171Snilay@cs.wisc.edu * this software without specific prior written permission. 159171Snilay@cs.wisc.edu * 169171Snilay@cs.wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179171Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189171Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199171Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209171Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219171Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229171Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239171Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249171Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259171Snilay@cs.wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269171Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279171Snilay@cs.wisc.edu */ 289171Snilay@cs.wisc.edu 299171Snilay@cs.wisc.edu#include "mem/ruby/common/Consumer.hh" 309171Snilay@cs.wisc.edu 3110123Snilay@cs.wisc.eduusing namespace std; 3210123Snilay@cs.wisc.edu 339171Snilay@cs.wisc.eduvoid 349499Snilay@cs.wisc.eduConsumer::scheduleEvent(Cycles timeDelta) 359171Snilay@cs.wisc.edu{ 369600Snilay@cs.wisc.edu scheduleEventAbsolute(em->clockEdge(timeDelta)); 379171Snilay@cs.wisc.edu} 389171Snilay@cs.wisc.edu 399171Snilay@cs.wisc.eduvoid 409600Snilay@cs.wisc.eduConsumer::scheduleEventAbsolute(Tick evt_time) 419171Snilay@cs.wisc.edu{ 429171Snilay@cs.wisc.edu if (!alreadyScheduled(evt_time)) { 439171Snilay@cs.wisc.edu // This wakeup is not redundant 4412133Sspwilson2@wisc.edu auto *evt = new EventFunctionWrapper( 4512133Sspwilson2@wisc.edu [this]{ wakeup(); }, "Consumer Event", true); 4612133Sspwilson2@wisc.edu 479171Snilay@cs.wisc.edu em->schedule(evt, evt_time); 489171Snilay@cs.wisc.edu insertScheduledWakeupTime(evt_time); 499171Snilay@cs.wisc.edu } 5010123Snilay@cs.wisc.edu 5110123Snilay@cs.wisc.edu Tick t = em->clockEdge(); 5210123Snilay@cs.wisc.edu set<Tick>::iterator bit = m_scheduled_wakeups.begin(); 5310123Snilay@cs.wisc.edu set<Tick>::iterator eit = m_scheduled_wakeups.lower_bound(t); 5410123Snilay@cs.wisc.edu m_scheduled_wakeups.erase(bit,eit); 559171Snilay@cs.wisc.edu} 56