Consumer.cc revision 9171
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#include "mem/ruby/common/Global.hh" 319171Snilay@cs.wisc.edu#include "mem/ruby/system/System.hh" 329171Snilay@cs.wisc.edu 339171Snilay@cs.wisc.eduvoid 349171Snilay@cs.wisc.eduConsumer::scheduleEvent(Time timeDelta) 359171Snilay@cs.wisc.edu{ 369171Snilay@cs.wisc.edu scheduleEvent(g_system_ptr, timeDelta); 379171Snilay@cs.wisc.edu} 389171Snilay@cs.wisc.edu 399171Snilay@cs.wisc.eduvoid 409171Snilay@cs.wisc.eduConsumer::scheduleEvent(EventManager *em, Time timeDelta) 419171Snilay@cs.wisc.edu{ 429171Snilay@cs.wisc.edu scheduleEventAbsolute(em, timeDelta + g_system_ptr->getTime()); 439171Snilay@cs.wisc.edu} 449171Snilay@cs.wisc.edu 459171Snilay@cs.wisc.eduvoid 469171Snilay@cs.wisc.eduConsumer::scheduleEventAbsolute(Time timeAbs) 479171Snilay@cs.wisc.edu{ 489171Snilay@cs.wisc.edu scheduleEventAbsolute(g_system_ptr, timeAbs); 499171Snilay@cs.wisc.edu} 509171Snilay@cs.wisc.edu 519171Snilay@cs.wisc.eduvoid 529171Snilay@cs.wisc.eduConsumer::scheduleEventAbsolute(EventManager *em, Time timeAbs) 539171Snilay@cs.wisc.edu{ 549171Snilay@cs.wisc.edu Tick evt_time = timeAbs * g_system_ptr->getClock(); 559171Snilay@cs.wisc.edu if (!alreadyScheduled(evt_time)) { 569171Snilay@cs.wisc.edu // This wakeup is not redundant 579171Snilay@cs.wisc.edu ConsumerEvent *evt = new ConsumerEvent(this); 589171Snilay@cs.wisc.edu assert(timeAbs > g_system_ptr->getTime()); 599171Snilay@cs.wisc.edu 609171Snilay@cs.wisc.edu em->schedule(evt, evt_time); 619171Snilay@cs.wisc.edu insertScheduledWakeupTime(evt_time); 629171Snilay@cs.wisc.edu } 639171Snilay@cs.wisc.edu} 64