Consumer.cc revision 9465
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 319171Snilay@cs.wisc.eduvoid 329171Snilay@cs.wisc.eduConsumer::scheduleEvent(Time timeDelta) 339171Snilay@cs.wisc.edu{ 349465Snilay@cs.wisc.edu scheduleEventAbsolute(timeDelta + em->curCycle()); 359171Snilay@cs.wisc.edu} 369171Snilay@cs.wisc.edu 379171Snilay@cs.wisc.eduvoid 389171Snilay@cs.wisc.eduConsumer::scheduleEventAbsolute(Time timeAbs) 399171Snilay@cs.wisc.edu{ 409465Snilay@cs.wisc.edu Tick evt_time = em->clockPeriod() * timeAbs; 419171Snilay@cs.wisc.edu if (!alreadyScheduled(evt_time)) { 429171Snilay@cs.wisc.edu // This wakeup is not redundant 439171Snilay@cs.wisc.edu ConsumerEvent *evt = new ConsumerEvent(this); 449465Snilay@cs.wisc.edu assert(timeAbs > em->curCycle()); 459171Snilay@cs.wisc.edu 469171Snilay@cs.wisc.edu em->schedule(evt, evt_time); 479171Snilay@cs.wisc.edu insertScheduledWakeupTime(evt_time); 489171Snilay@cs.wisc.edu } 499171Snilay@cs.wisc.edu} 50