Revision c6940301 src/sim/csimulation.cc

View differences:

src/sim/csimulation.cc
633 633

  
634 634
void cSimulation::doOneEvent()
635 635
{
636
    cSimpleModule* mod = NULL; //TODO FIXME?
636
    cMessage * msg = NULL;
637
    cSimpleModule* mod = NULL;
638

  
637 639
#ifndef NDEBUG
638 640
    checkActive();
639 641
#endif
642

  
640 643
    try
641 644
    {
642
        cMessage * msg;
643

  
644 645
#ifdef NOBARRIER
646
        //TODO move to scheduler?
645 647
        // Do we have to wait for a barrier?
646 648
        if(threaded) {
647 649
            barrierMin = threadPool->waitAtBarrier(barrierMin, &msgQueue);
648 650
        }
649 651
#endif
652

  
650 653
        msg = schedulerp->getNextEvent();
654

  
651 655
        //Advance Simulation Time
656
        //TODO Move to scheduler? (only in case of barrier)
652 657
        cThreadPool::setSimTime(msg->getArrivalTime());
653 658

  
654 659
#ifndef NOBARRIER
660
        //TODO: move to scheduler
655 661
        // check if this is an barrier message indicating the end of an event
656 662
        cBarrierMessage* barrier = dynamic_cast<cBarrierMessage*> (msg);
657 663
        if (barrier != NULL) {
......
681 687
            cAsyncModule* aMod = (cAsyncModule*) mod;
682 688

  
683 689
            simtime_t duration = aMod->getProcessingDelay(msg);
684
            bool mayPar = aMod->mayParallelize(msg, duration);
685 690

  
686 691
            if (duration < SimTime::simTimeZero) {
687 692
                throw cRuntimeError("negative event duration not allowed.");
688 693
            }
689

  
690
#ifndef NOBARRIER
691
            simtime_t now = cThreadPool::getSimTime();
692
#endif
693 694
            msg->setEventDuration(duration);
695

  
696
            bool mayPar = aMod->mayParallelize(msg, duration);
694 697
            // execute this event in parallel
695 698
            if (mayPar && threaded) {
696
#ifndef NOBARRIER
697
                /*
698
                 * MOVED TO cSCHEDULER.cc
699
                // create a new barrier and schedule it
700
                cBarrierMessage* barrier = new cBarrierMessage();
701
                barrier->setArrival(mod, -1, now + duration);
702
                simulation.msgQueue.insert(barrier);
703
                // insert user supplied message in task queue.
704
                msg->setBarrier(barrier);*/
705
#endif
706 699
                // block if another thread is busy inside this module
707 700
                // then set the module to busy
708 701
                aMod->waitIfBusy();
709 702
                aMod->setBusy();
710
                //Debugoutput
711 703
                //printf("Offloading: %s\n",mod->getName());
712 704
                barrierMin = threadPool->insertTask(msg, duration, barrierMin);
713 705
            } else {
......
763 755
        setGlobalContext();
764 756
        throw e2;
765 757
    }
766

  
767
    // Note: simulation time (as read via simTime() from modules) is updated
768
    // in selectNextModule()) called right before the next doOneEvent().
769
    // It must not be updated here, because it will interfere with parallel
770
    // simulation (cIdealSimulationProtocol, etc) that relies on simTime()
771
    // returning the time of the last executed event. If Tkenv wants to display
772
    // the time of the next event, it should call guessNextSimtime().
773 758
}
774 759

  
775 760
void cSimulation::transferToMain()

Also available in: Unified diff