Revision fbe00e73 src/sim/cscheduler.cc

View differences:

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

  
32 33
USING_NAMESPACE
33 34

  
......
121 122
    }
122 123

  
123 124
    cSimpleModule* mod = (cSimpleModule*) sim->getModule(msg->getArrivalModuleId());
124
    if (mod->isAsyncModule())
125
    {
126
        cAsyncModule* aMod = (cAsyncModule*) mod;
127
        simtime_t duration = msg->getEventDuration();
128
        if (duration != SimTime::simTimeSequentialExecution && aMod->mayParallelize(msg, duration) && sim->threadPool)
129
        {
130
            //
131
            // create a new barrier and schedule it
132
            //
133
            cBarrierMessage* barrier = new cBarrierMessage();
134
            barrier->setArrival(aMod, -1, msg->getArrivalTime() + duration);
135
            msg->setBarrier(barrier);
136

  
137
            // If the event is a null duration event,
138
            // we have to set additional data in the barrier
139
            // to make sure the barrier gets placed correctly
140
            barrier->setSchedulingPriority(msg->getSchedulingPriority());
141
            barrier->setParentStartTime(msg->getArrivalTime());
142
            barrier->setParentExecutionOrderId(sim->getNextExecutionOrderId(msg));
143
            // Set scheduling order to 0 (in front of all children)
144
            barrier->setSchedulingOrderId(0);
145

  
146
            sim->msgQueue.insert(barrier);
147
        }
148
    }
125
	simtime_t duration = msg->getEventDuration();
126
	if (duration != SimTime::simTimeSequentialExecution && mod->mayParallelize(msg, duration) && sim->threadPool)
127
	{
128
		//
129
		// create a new barrier and schedule it
130
		//
131
		cBarrierMessage* barrier = new cBarrierMessage();
132
		barrier->setArrival(mod, -1, msg->getArrivalTime() + duration);
133
		msg->setBarrier(barrier);
134

  
135
		// If the event is a null duration event,
136
		// we have to set additional data in the barrier
137
		// to make sure the barrier gets placed correctly
138
		barrier->setSchedulingPriority(msg->getSchedulingPriority());
139
		barrier->setParentStartTime(msg->getArrivalTime());
140
		barrier->setParentExecutionOrderId(sim->getNextExecutionOrderId(msg));
141
		// Set scheduling order to 0 (in front of all children)
142
		barrier->setSchedulingOrderId(0);
143

  
144
		sim->msgQueue.insert(barrier);
145
	}
149 146
    return msg;
150 147
#endif
151 148
}
......
175 172
void cEEFScheduler::updateIES() {
176 173
    cMessage *msg = NULL;
177 174
    cSimpleModule* mod = NULL;
178
    cAsyncModule* aMod = NULL;
179 175
#ifdef NOBARRIER
180 176

  
181 177
    while (!(sim->msgQueue.empty()))
......
184 180

  
185 181
        mod = (cSimpleModule*) sim->getModule(msg->getArrivalModuleId());
186 182

  
187
        if (!(mod->isAsyncModule())) {
188
            break;
189
        }
190

  
191
        aMod = (cAsyncModule*) mod;
192 183
        simtime_t duration = msg->getEventDuration();
193 184

  
194
        if (!aMod->mayParallelize(msg, duration)) {
185
        if (!mod->mayParallelize(msg, duration)) {
195 186
            break;
196 187
        }
197 188

  
......
262 253
        }
263 254

  
264 255
        mod = (cSimpleModule*) sim->getModule(msg->getArrivalModuleId());
265
        aMod = NULL;
266
        if (mod->isAsyncModule())
267
        {
268
            aMod = (cAsyncModule*) mod;
269
            simtime_t duration = msg->getEventDuration();
270

  
271
            if (!aMod->mayParallelize(msg, duration))
272
            {
273
                sim->msgQueue.insert(msg);
274
                return;
275
            }
276
            // create a new barrier and schedule it
277
            cBarrierMessage* barrier = new cBarrierMessage();
278
            barrier->setArrival(aMod, -1, msg->getArrivalTime() + duration);
279
            msg->setBarrier(barrier);
280
            sim->msgQueue.insert(barrier);
281

  
282
/*            printf(
283
                    "adding to IEH: %s, tstart=%f, tend= %f, now First in IEH: ",
284
                    ((cSimpleModule*) sim->getModule(msg->getArrivalModuleId()))->getName(),SIMTIME_DBL(msg->getArrivalTime()),
285
                    SIMTIME_DBL(msg->getTend()));*/
286

  
287
            independentEventsHeap.insert(msg);
288

  
289
/*            printf(
290
                    "%s, length=%i\n",
291
                    ((cSimpleModule*) sim->getModule(
292
                            independentEventsHeap.peekFirst()->getArrivalModuleId()))->getName(),
293
                    independentEventsHeap.length());*/
294

  
295
        }
296
        else //Not a AsyncModule
297
        {
298
            sim->msgQueue.insert(msg);
299
            return;
300
        }
256
		simtime_t duration = msg->getEventDuration();
257

  
258
		if (!mod->mayParallelize(msg, duration))
259
		{
260
			sim->msgQueue.insert(msg);
261
			return;
262
		}
263
		// create a new barrier and schedule it
264
		cBarrierMessage* barrier = new cBarrierMessage();
265
		barrier->setArrival(mod, -1, msg->getArrivalTime() + duration);
266
		msg->setBarrier(barrier);
267
		sim->msgQueue.insert(barrier);
268

  
269
		independentEventsHeap.insert(msg);
301 270

  
302 271
    } // while (!(sim->msgQueue.empty()))
303 272
#endif

Also available in: Unified diff