Revision 94cf1056

View differences:

configure.user
18 18
#    yes -> no NOT use barrier messages
19 19
#    no  -> use barrier messages
20 20
#
21
NOBARRIER=yes
21
NOBARRIER=no
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/cbarriermessage.h
45 45
  private:
46 46
    // the semaphore used to block the calling thread on calling wait()
47 47
    sem_t sem;
48
    bool valid; //set to false if barrier has already been signaled
48 49

  
49 50
  public:
50 51
    /** @name Constructor and destructor and stuff */
......
128 129
    inline void signal()
129 130
    {
130 131
        sem_post(&sem);
132
        valid = false;
133
    }
134

  
135
    inline bool isValid() {
136
        return valid;
131 137
    }
132 138
    //@}
133 139
};
src/sim/cbarriermessage.cc
23 23
#include "cbarriermessage.h"
24 24

  
25 25
cBarrierMessage::cBarrierMessage() :
26
    cMessage("BarrierMessage")
26
    cMessage("BarrierMessage"), valid(true)
27 27
{
28 28
    sem_init(&sem, 0, 0);
29 29
}
src/sim/cscheduler.cc
145 145
        cAsyncModule* aMod = (cAsyncModule*) mod;
146 146
        simtime_t now = msg->getArrivalTime();
147 147
        simtime_t duration = aMod->getProcessingDelay(msg);
148
        msg->setEventDuration(duration);
148 149

  
149 150
        if (aMod->mayParallelize(msg, duration))
150 151
        {
151
            msg->setEventDuration(duration);
152 152
            // create a new barrier and schedule it
153 153
            cBarrierMessage* barrier = new cBarrierMessage();
154 154
            barrier->setArrival(aMod, -1, now + duration);
155 155
            msg->setBarrier(barrier);
156
            // insert user supplied message in task queue.
157 156
            sim->msgQueue.insert(barrier);
158 157
        }
159 158
    }
......
281 280
        if (barrier != NULL)
282 281
        {
283 282
            /*
283
             * If the barrier has already been signaled, we can just delete it, as we would not have to wait here
284
            */
285
            if(!barrier->isValid()) {
286
                delete barrier;
287
                continue;
288
            }
289
            /*
284 290
             * if we hit a barrier, we are done and return the first independent msg
285 291
             * or we have wait at the barrier if no independent event exists
286 292
             */
......
325 331
            sim->msgQueue.insert(barrier);
326 332

  
327 333
            printf(
328
                     "adding to IEH: %s, tstart=%f, tend= %f, now First in IEH: ", SIMTIME_DBL(msg->getArrivalTime()),
334
                     "adding to IEH: %f, tstart=%s, tend= %f, now First in IEH: ", SIMTIME_DBL(msg->getArrivalTime()),
329 335
                     ((cSimpleModule*) sim->getModule(msg->getArrivalModuleId()))->getName(),
330 336
                     SIMTIME_DBL(msg->getTend()));
331 337

  

Also available in: Unified diff