Project

General

Profile

Revision 96e929a8

ID96e929a8aca87819d829629798726a90312b8093

Added by Simon Tenbusch over 9 years ago

[eefscheduler] encapsulated getProcessingDelay-call in the getEventDuration() of cMessage
The duration of a message is invalidated in scheduleAt and sendDirect/Delayed

View differences:

configure.user
18 18
#    yes -> no NOT use barrier messages
19 19
#    no  -> use barrier messages
20 20
#
21
NOBARRIER=no
21
NOBARRIER=yes
22 22
#
23 23
# In combination with NOBARRIER: Define the cache line size used for aligning
24 24
# synchronization data structures to cache line borders.
include/cmessage.h
25 25
#include "cmsgpar.h"
26 26
#include "csimulation.h"
27 27

  
28

  
28 29
#ifdef ATOMIC_OPS_DEBUG
29 30
#include "catomicopsdebug.h"
30 31
#else
......
208 209
    /**
209 210
     * Returns the duration of this event.
210 211
     */
211
    inline simtime_t getEventDuration() const   {return duration;}
212
    simtime_t getEventDuration();
212 213

  
213 214
    /**
214 215
     * Sets the duration of this event.
src/sim/casyncmodule.cc
70 70

  
71 71
int cAsyncModule::scheduleAt(simtime_t t, cMessage *msg)
72 72
{
73
    msg->setEventDuration(-1);
74

  
73 75
    //
74 76
    // check current state
75 77
    //
......
88 90
        // message it will trigger the processing of the associated task
89 91
        msg->setSentFrom(this, -1, t_end);
90 92
        msg->setArrival(this, -1, t);
93

  
94

  
91 95
        simulation.msgQueue.insert(msg);
92 96
        return 0;
93 97
    }
......
213 217

  
214 218
int cAsyncModule::sendDelayed(cMessage *msg, simtime_t delay, cGate *outputgate)
215 219
{
220
    msg->setEventDuration(-1);
221

  
216 222
    //
217 223
    // check current state
218 224
    //
......
309 315

  
310 316
int cAsyncModule::sendDirect(cMessage *msg, simtime_t delay, simtime_t duration, cGate *togate)
311 317
{
318

  
319
    msg->setEventDuration(-1);
320

  
312 321
    //
313 322
    // check current state
314 323
    //
......
364 373

  
365 374
        msg->setSentFrom(this, -1, time);
366 375

  
376

  
377

  
367 378
        bool keepit = togate->deliver(msg, time + delay);
368 379
        if (!keepit)
369 380
                delete msg;
src/sim/clockedthreadpool.cc
140 140
        delta_t(&diff, &then, &now);
141 141
        std::cout << diff.tv_sec + diff.tv_nsec / 1000000000.0 << std::endl;
142 142
#endif
143

  
144 143
        //
145 144
        // indicate that the thread has finished
146 145
		//
src/sim/cmessage.cc
27 27
#include "cmessage.h"
28 28
#include "cexception.h"
29 29
#include "cenvir.h"
30
#include "casyncmodule.h"
30 31

  
31 32
#ifdef WITH_PARSIM
32 33
#include "ccommbuffer.h"
......
82 83
    prev_event_num = -1;
83 84

  
84 85
    duration = -1;
85

  
86 86
    msgtreeid = msgid = AO_fetch_and_add1(&next_id);
87 87
    AO_fetch_and_add1(&total_msgs);
88 88
    AO_fetch_and_add1(&live_msgs);
......
363 363
    delivd = t;
364 364
}
365 365

  
366
simtime_t cMessage::getEventDuration() {
367
    if (duration < 0) {
368
        cSimpleModule* mod = (cSimpleModule*) simulation.getModule(getArrivalModuleId());
369
        if (mod->isAsyncModule()) {
370
            duration = ((cAsyncModule*) mod)->getProcessingDelay(this);
371
        }
372
    }
373
    return duration;
374
}
375

  
366 376
//----
367 377

  
368 378
cPacket::cPacket(const cPacket& pkt) : cMessage(pkt)
......
656 666

  
657 667

  
658 668

  
659

  
src/sim/cscheduler.cc
61 61
    //
62 62
    cMessage *msg = sim->msgQueue.removeFirst();
63 63

  
64
    if (msg) {
65
        /*
66
         * Set Duration
67
         */
68
        cSimpleModule* mod = (cSimpleModule*) sim->getModule(msg->getArrivalModuleId());
69
        if (mod->isAsyncModule()) {
70
            msg->setEventDuration(((cAsyncModule*) mod)->getProcessingDelay(msg));
71
        }
72
        /*
73
         * return message
74
         */
75
        return msg;
76
    }
64
    if (msg) return msg;
77 65

  
78 66

  
79 67
    //
......
95 83
    //
96 84
    // If there is a msg now, we return it:
97 85
    //
98
    if (msg) {
99
        /*
100
         * Set Duration
101
         */
102
        cSimpleModule* mod = (cSimpleModule*) sim->getModule(msg->getArrivalModuleId());
103
        if (mod->isAsyncModule()) {
104
            msg->setEventDuration(((cAsyncModule*) mod)->getProcessingDelay(msg));
105
        }
106
        /*
107
         * return message
108
         */
109
        return msg;
110
    }
86
    if (msg) return msg;
111 87

  
112 88
    //
113 89
    // If there is still no message in the queue, there are
......
144 120
    {
145 121
        cAsyncModule* aMod = (cAsyncModule*) mod;
146 122
        simtime_t now = msg->getArrivalTime();
147
        simtime_t duration = aMod->getProcessingDelay(msg);
148
        msg->setEventDuration(duration);
123
        simtime_t duration = msg->getEventDuration();
149 124

  
150 125
        if (aMod->mayParallelize(msg, duration))
151 126
        {
......
191 166
        if (!(mod->isAsyncModule())) {
192 167
            break;
193 168
        }
169

  
194 170
        aMod = (cAsyncModule*) mod;
195
        simtime_t duration = aMod->getProcessingDelay(msg);
196
        msg->setEventDuration(duration);
197
        bool mayPar = aMod->mayParallelize(msg, duration);
171
        simtime_t duration = msg->getEventDuration();
198 172

  
199
        if (!mayPar) {
173
        if (!aMod->mayParallelize(msg, duration)) {
200 174
            break;
201 175
        }
202 176
        /*
......
254 228
    }
255 229
    msg = sim->msgQueue.removeFirst();
256 230

  
257
    //
258
    // If there is a msg now, we return it:
259
    //
260
    if (msg)
261
    return msg;
231
    if (msg) return msg;
262 232

  
263 233
    //
264 234
    // If there is still no message in the queue, there are
......
309 279
        {
310 280
            aMod = (cAsyncModule*) mod;
311 281
            simtime_t now = msg->getArrivalTime();
312
            simtime_t duration = aMod->getProcessingDelay(msg);
313
            msg->setEventDuration(duration);
282
            simtime_t duration = msg->getEventDuration();
314 283

  
315 284
            if (!aMod->mayParallelize(msg, duration))
316 285
            {
......
331 300
            sim->msgQueue.insert(barrier);
332 301

  
333 302
            printf(
334
                     "adding to IEH: %f, tstart=%s, tend= %f, now First in IEH: ", SIMTIME_DBL(msg->getArrivalTime()),
335
                     ((cSimpleModule*) sim->getModule(msg->getArrivalModuleId()))->getName(),
336
                     SIMTIME_DBL(msg->getTend()));
303
                    "adding to IEH: %s, tstart=%f, tend= %f, now First in IEH: ",
304
                    ((cSimpleModule*) sim->getModule(msg->getArrivalModuleId()))->getName(),SIMTIME_DBL(msg->getArrivalTime()),
305
                    SIMTIME_DBL(msg->getTend()));
337 306

  
338 307
            independentEventsHeap.insert(msg);
339 308

  
src/sim/csimulation.cc
675 675
                // then set the module to busy
676 676
                aMod->waitIfBusy();
677 677
                aMod->setBusy();
678
                //printf("Offloading: %s\n",mod->getName());
678
                printf("Offloading: %s\n",mod->getName());
679 679
                threadPool->insertTask(msg, duration);
680 680
            }
681 681
            else

Also available in: Unified diff