summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKorey Sewell <ksewell@umich.edu>2009-05-12 15:01:16 -0400
committerKorey Sewell <ksewell@umich.edu>2009-05-12 15:01:16 -0400
commit6c88730540da3ecfdf32ab798eb60e4a24935789 (patch)
treef3289908cdedf135dc290f7fdd26dd6bae0f9d9a
parentdb2b72138052ad96d808d8286bd2598c96f96a31 (diff)
downloadgem5-6c88730540da3ecfdf32ab798eb60e4a24935789.tar.xz
inorder-resources: delete events
make sure unrecognized events in the resource pool are deleted and also delete resource events in destructor
-rw-r--r--src/cpu/inorder/resource.cc6
-rw-r--r--src/cpu/inorder/resource.hh3
-rw-r--r--src/cpu/inorder/resource_pool.cc66
-rw-r--r--src/cpu/inorder/resource_pool.hh8
4 files changed, 54 insertions, 29 deletions
diff --git a/src/cpu/inorder/resource.cc b/src/cpu/inorder/resource.cc
index d8fefe0c9..49afefd98 100644
--- a/src/cpu/inorder/resource.cc
+++ b/src/cpu/inorder/resource.cc
@@ -44,6 +44,12 @@ Resource::Resource(string res_name, int res_id, int res_width,
deniedReq = new ResourceRequest(this, NULL, 0, 0, 0, 0);
}
+Resource::~Resource()
+{
+ delete [] resourceEvent;
+}
+
+
void
Resource::init()
{
diff --git a/src/cpu/inorder/resource.hh b/src/cpu/inorder/resource.hh
index 71270241f..5b4977158 100644
--- a/src/cpu/inorder/resource.hh
+++ b/src/cpu/inorder/resource.hh
@@ -60,7 +60,8 @@ class Resource {
public:
Resource(std::string res_name, int res_id, int res_width,
int res_latency, InOrderCPU *_cpu);
- virtual ~Resource() {}
+ virtual ~Resource();
+
/** Return name of this resource */
virtual std::string name();
diff --git a/src/cpu/inorder/resource_pool.cc b/src/cpu/inorder/resource_pool.cc
index 5cb55b89b..7bcf2585b 100644
--- a/src/cpu/inorder/resource_pool.cc
+++ b/src/cpu/inorder/resource_pool.cc
@@ -187,19 +187,18 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
{
assert(delay >= 0);
- ResPoolEvent *res_pool_event = new ResPoolEvent(this);
-
switch (e_type)
{
case InOrderCPU::ActivateThread:
{
DPRINTF(Resource, "Scheduling Activate Thread Resource Pool Event for tick %i.\n",
curTick + delay);
- res_pool_event->setEvent(e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- inst->readTid());
+ ResPoolEvent *res_pool_event = new ResPoolEvent(this,
+ e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ inst->readTid());
mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
}
break;
@@ -207,14 +206,15 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
case InOrderCPU::SuspendThread:
case InOrderCPU::DeallocateThread:
{
+
DPRINTF(Resource, "Scheduling Deactivate Thread Resource Pool Event for tick %i.\n",
curTick + delay);
-
- res_pool_event->setEvent(e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- tid);
+ ResPoolEvent *res_pool_event = new ResPoolEvent(this,
+ e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ tid);
mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
@@ -225,12 +225,11 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
{
DPRINTF(Resource, "Scheduling Inst-Graduated Resource Pool Event for tick %i.\n",
curTick + delay);
-
- res_pool_event->setEvent(e_type,
- inst,
- inst->squashingStage,
- inst->seqNum,
- inst->readTid());
+ ResPoolEvent *res_pool_event = new ResPoolEvent(this,e_type,
+ inst,
+ inst->squashingStage,
+ inst->seqNum,
+ inst->readTid());
mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
}
@@ -240,13 +239,12 @@ ResourcePool::scheduleEvent(InOrderCPU::CPUEventType e_type, DynInstPtr inst,
{
DPRINTF(Resource, "Scheduling Squash Resource Pool Event for tick %i.\n",
curTick + delay);
- res_pool_event->setEvent(e_type,
- inst,
- inst->squashingStage,
- inst->bdelaySeqNum,
- inst->readTid());
+ ResPoolEvent *res_pool_event = new ResPoolEvent(this,e_type,
+ inst,
+ inst->squashingStage,
+ inst->bdelaySeqNum,
+ inst->readTid());
mainEventQueue.schedule(res_pool_event, curTick + cpu->ticks(delay));
-
}
break;
@@ -315,9 +313,21 @@ ResourcePool::instGraduated(InstSeqNum seq_num,unsigned tid)
}
ResourcePool::ResPoolEvent::ResPoolEvent(ResourcePool *_resPool)
- : Event(CPU_Tick_Pri),
- resPool(_resPool)
-{ eventType = (InOrderCPU::CPUEventType) Default; }
+ : Event(CPU_Tick_Pri), resPool(_resPool),
+ eventType((InOrderCPU::CPUEventType) Default)
+{ }
+
+ResourcePool::ResPoolEvent::ResPoolEvent(ResourcePool *_resPool,
+ InOrderCPU::CPUEventType e_type,
+ DynInstPtr _inst,
+ int stage_num,
+ InstSeqNum seq_num,
+ unsigned _tid)
+ : Event(CPU_Tick_Pri), resPool(_resPool),
+ eventType(e_type), inst(_inst), seqNum(seq_num),
+ stageNum(stage_num), tid(_tid)
+{ }
+
void
ResourcePool::ResPoolEvent::process()
diff --git a/src/cpu/inorder/resource_pool.hh b/src/cpu/inorder/resource_pool.hh
index 6cc1f77e6..42a07390c 100644
--- a/src/cpu/inorder/resource_pool.hh
+++ b/src/cpu/inorder/resource_pool.hh
@@ -87,6 +87,14 @@ class ResourcePool {
/** Constructs a resource event. */
ResPoolEvent(ResourcePool *_resPool);
+ /** Constructs a resource event. */
+ ResPoolEvent(ResourcePool *_resPool,
+ InOrderCPU::CPUEventType e_type,
+ DynInstPtr _inst,
+ int stage_num,
+ InstSeqNum seq_num,
+ unsigned _tid);
+
/** Set Type of Event To Be Scheduled */
void setEvent(InOrderCPU::CPUEventType e_type,
DynInstPtr _inst,