eventq_impl.hh revision 9356
12817Sksewell@umich.edu/*
27763SAli.Saidi@ARM.com * Copyright (c) 2012 The Regents of The University of Michigan
37763SAli.Saidi@ARM.com * Copyright (c) 2012 Mark D. Hill and David A. Wood
47763SAli.Saidi@ARM.com * All rights reserved.
57763SAli.Saidi@ARM.com *
67763SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without
77763SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are
87763SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright
97763SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer;
107763SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright
117763SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the
127763SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution;
137763SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its
142817Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
152817Sksewell@umich.edu * this software without specific prior written permission.
162817Sksewell@umich.edu *
172817Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182817Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192817Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202817Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212817Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222817Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232817Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242817Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252817Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262817Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272817Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282817Sksewell@umich.edu *
292817Sksewell@umich.edu * Authors: Steve Reinhardt
302817Sksewell@umich.edu *          Nathan Binkert
312817Sksewell@umich.edu *          Nilay Vaish
322817Sksewell@umich.edu */
332817Sksewell@umich.edu
342817Sksewell@umich.edu#ifndef __SIM_EVENTQ_IMPL_HH__
352817Sksewell@umich.edu#define __SIM_EVENTQ_IMPL_HH__
362817Sksewell@umich.edu
372817Sksewell@umich.edu#include "base/trace.hh"
382817Sksewell@umich.edu#include "sim/eventq.hh"
392817Sksewell@umich.edu
402817Sksewell@umich.eduinline void
412817Sksewell@umich.eduEventQueue::schedule(Event *event, Tick when)
422817Sksewell@umich.edu{
432817Sksewell@umich.edu    assert(when >= getCurTick());
446329Sgblack@eecs.umich.edu    assert(!event->scheduled());
456658Snate@binkert.org    assert(event->initialized());
462817Sksewell@umich.edu
472834Sksewell@umich.edu    event->setWhen(when, this);
482817Sksewell@umich.edu    insert(event);
492817Sksewell@umich.edu    event->flags.set(Event::Scheduled);
502817Sksewell@umich.edu    if (this == &mainEventQueue)
512817Sksewell@umich.edu        event->flags.set(Event::IsMainQueue);
525499Ssaidi@eecs.umich.edu    else
532817Sksewell@umich.edu        event->flags.clear(Event::IsMainQueue);
545499Ssaidi@eecs.umich.edu
552817Sksewell@umich.edu    if (DTRACE(Event))
562817Sksewell@umich.edu        event->trace("scheduled");
572817Sksewell@umich.edu}
582817Sksewell@umich.edu
592817Sksewell@umich.eduinline void
602817Sksewell@umich.eduEventQueue::deschedule(Event *event)
613126Sktlim@umich.edu{
622817Sksewell@umich.edu    assert(event->scheduled());
632817Sksewell@umich.edu    assert(event->initialized());
642817Sksewell@umich.edu
652817Sksewell@umich.edu    remove(event);
662817Sksewell@umich.edu
672817Sksewell@umich.edu    event->flags.clear(Event::Squashed);
682817Sksewell@umich.edu    event->flags.clear(Event::Scheduled);
692817Sksewell@umich.edu
707467Stjones1@inf.ed.ac.uk    if (DTRACE(Event))
712817Sksewell@umich.edu        event->trace("descheduled");
727467Stjones1@inf.ed.ac.uk
732817Sksewell@umich.edu    if (event->flags.isSet(Event::AutoDelete))
742817Sksewell@umich.edu        delete event;
752817Sksewell@umich.edu}
762817Sksewell@umich.edu
772817Sksewell@umich.eduinline void
782817Sksewell@umich.eduEventQueue::reschedule(Event *event, Tick when, bool always)
795714Shsul@eecs.umich.edu{
805715Shsul@eecs.umich.edu    assert(when >= getCurTick());
812817Sksewell@umich.edu    assert(always || event->scheduled());
822817Sksewell@umich.edu    assert(event->initialized());
832817Sksewell@umich.edu
842817Sksewell@umich.edu    if (event->scheduled())
852817Sksewell@umich.edu        remove(event);
862817Sksewell@umich.edu
872817Sksewell@umich.edu    event->setWhen(when, this);
882817Sksewell@umich.edu    insert(event);
892817Sksewell@umich.edu    event->flags.clear(Event::Squashed);
902817Sksewell@umich.edu    event->flags.set(Event::Scheduled);
912817Sksewell@umich.edu    if (this == &mainEventQueue)
922817Sksewell@umich.edu        event->flags.set(Event::IsMainQueue);
932817Sksewell@umich.edu    else
942817Sksewell@umich.edu        event->flags.clear(Event::IsMainQueue);
952817Sksewell@umich.edu
962817Sksewell@umich.edu    if (DTRACE(Event))
972817Sksewell@umich.edu        event->trace("rescheduled");
982817Sksewell@umich.edu}
992817Sksewell@umich.edu
1002817Sksewell@umich.edu#endif // __SIM_EVENTQ_IMPL_HH__
1016029Ssteve.reinhardt@amd.com