Revision a3d116e3 src/sim/cscheduler.cc

View differences:

src/sim/cscheduler.cc
27 27
#include "cconfiguration.h"
28 28
#include "cconfigoption.h"
29 29
#include "platmisc.h" // usleep
30
#include "cbarriermessage.h"
30 31

  
31 32
USING_NAMESPACE
32 33

  
......
98 99
}
99 100

  
100 101
//-----
102
Register_Class(cEEFScheduler)
103
;
101 104

  
105
cEEFScheduler::cEEFScheduler()
106
{
107
}
108
cEEFScheduler::~cEEFScheduler()
109
{
110
}
111

  
112
cMessage *cEEFScheduler::getNextEvent()
113
{
114
#ifdef NOBARRIER
115
    //
116
    // If we retrieve a valid msg from the queue, we return it:
117
    //
118
    cMessage *msg = sim->msgQueue.peekFirst();
119
    if (msg)
120
    return msg;
121

  
122
    //
123
    // if there is no event left and we don't use the threadpool, end the sim
124
    //
125
    if (!sim->threadPool)
126
    throw cTerminationException(eENDEDOK);
127

  
128
    //
129
    // If we did not get a valid msg from the queue, but there are still
130
    // barrier messages left, we wait:
131
    //
132
    while (sim->msgQueue.empty() && !sim->threadPool->barrierEmpty())
133
    {
134
        __asm__ ("pause");
135
    }
136
    msg = sim->msgQueue.peekFirst();
137

  
138
    //
139
    // If there is a msg now, we return it:
140
    //
141
    if (msg)
142
    return msg;
143

  
144
    //
145
    // If there is still no message in the queue, there are
146
    // also no barriers left (else we would have waited), and we quit:
147
    //
148

  
149
    else
150
    throw cTerminationException(eENDEDOK);
151

  
152
#else
153
    cMessage *msg;
154
    cBarrierMessage* barrier;
155
    while (!sim->msgQueue.empty())
156
    {
157
        msg = sim->msgQueue.peekFirst();
158
        barrier = dynamic_cast<cBarrierMessage*> (msg);
159
        if (barrier != NULL)
160
        {
161
            return independentEventsHeap.empty() ? msg
162
                    : independentEventsHeap.peekFirst();
163
        }
164
        independentEventsHeap.insert(sim->msgQueue.removeFirst());
165
    }
166
    if (independentEventsHeap.empty()) {
167
        throw cTerminationException(eENDEDOK);
168
    }
169
    return independentEventsHeap.peekFirst();
170
#endif
171
}
172

  
173
cMessage* cEEFScheduler::removeNextEvent() {
174
    printf ("Test");
175
    return independentEventsHeap.empty() ? sim->msgQueue.removeFirst() : independentEventsHeap.getFirst();
176
}
177

  
178
//-----
102 179
Register_Class(cRealTimeScheduler);
103 180

  
104 181
void cRealTimeScheduler::startRun()

Also available in: Unified diff