1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 29 unchanged lines hidden (view full) ---

38#include <cassert>
39#include <functional>
40#include <iostream>
41#include <string>
42#include <vector>
43
44#include "mem/ruby/common/Address.hh"
45#include "mem/ruby/common/Consumer.hh"
46#include "mem/ruby/network/MessageBufferNode.hh"
46#include "mem/ruby/slicc_interface/Message.hh"
47#include "mem/packet.hh"
48
49class MessageBuffer
50{
51 public:
52 MessageBuffer(const std::string &name = "");
53

--- 7 unchanged lines hidden (view full) ---

61 void stallMessage(const Address& addr);
62
63 // TRUE if head of queue timestamp <= SystemTime
64 bool isReady() const;
65
66 void
67 delayHead()
68 {
70 MessageBufferNode node = m_prio_heap.front();
69 MsgPtr m = m_prio_heap.front();
70 std::pop_heap(m_prio_heap.begin(), m_prio_heap.end(),
72 std::greater<MessageBufferNode>());
71 std::greater<MsgPtr>());
72 m_prio_heap.pop_back();
74 enqueue(node.m_msgptr, Cycles(1));
73 enqueue(m, Cycles(1));
74 }
75
76 bool areNSlotsAvailable(unsigned int n);
77 int getPriority() { return m_priority_rank; }
78 void setPriority(int rank) { m_priority_rank = rank; }
79 void setConsumer(Consumer* consumer)
80 {
81 if (m_consumer != NULL) {

--- 24 unchanged lines hidden (view full) ---

106 //! Function for extracting the message at the head of the
107 //! message queue. The function assumes that the queue is nonempty.
108 const Message* peek() const;
109
110 const MsgPtr&
111 peekMsgPtr() const
112 {
113 assert(isReady());
115 return m_prio_heap.front().m_msgptr;
114 return m_prio_heap.front();
115 }
116
117 void enqueue(MsgPtr message) { enqueue(message, Cycles(1)); }
118 void enqueue(MsgPtr message, Cycles delta);
119
120 //! Updates the delay cycles of the message at the head of the queue,
121 //! removes it from the queue and returns its total delay.
122 Cycles dequeue();

--- 39 unchanged lines hidden (view full) ---

162
163 // Data Members (m_ prefix)
164 //! The two ends of the buffer.
165 ClockedObject* m_sender;
166 ClockedObject* m_receiver;
167
168 //! Consumer to signal a wakeup(), can be NULL
169 Consumer* m_consumer;
171 std::vector<MessageBufferNode> m_prio_heap;
170 std::vector<MsgPtr> m_prio_heap;
171
172 // use a std::map for the stalled messages as this container is
173 // sorted and ensures a well-defined iteration order
174 typedef std::map< Address, std::list<MsgPtr> > StallMsgMapType;
175
176 StallMsgMapType m_stall_msg_map;
177 std::string m_name;
178

--- 36 unchanged lines hidden ---