Example #1
0
 void TaskContext::disconnectPeers( const std::string& name )
 {
     if ( _task_map.end() != _task_map.find( name ) ) {
         TaskContext* peer = _task_map.find(name)->second;
         this->removePeer(peer);
         peer->removePeer(this);
     }
 }
void PooledTaskListView::listBoxItemDoubleClicked(int row, const MouseEvent&)
{
	TaskContext* handler = getTaskForRow (row);
	if (handler != nullptr)
	{
		handler->getTask().abort();
	}
}
Example #3
0
 PortsTestFixture()
 {
     tc =  new TaskContext( "root", TaskContext::Stopped );
     tce = new EventPortsTC();
     tc2 = new EventPortsTC();
     tce->setActivity( new SequentialActivity() );
     tc2->setActivity( new SequentialActivity() );
     tc->setActivity( new SimulationActivity(0.001) );
     tsim = tc->getActivity();
     stsim = tc->getActivity();
     SimulationThread::Instance()->stop();
 }
Example #4
0
void DInst::notifyDataDepViolation(DataDepViolationAt dAt, bool val)
{
  I(!(val && restartVer));
  if (restartVer==0)
    return;

  TaskContext *tc = restartVer->getTaskContext();
  if (tc)
    tc->invalidMemAccess(dataDepViolationID, dAt);
  
  restartVer->garbageCollect();
  restartVer = 0;
}
Example #5
0
 void ExecutionEngine::setExceptionTask() {
     std::string name;
     TaskContext* tc = dynamic_cast<TaskContext*>(taskc);
     if (tc)
         name = tc->getName();
     else if (taskc)
         name = "TaskCore";
     else
         name = "GlobalEngine";
     log(Error) << "in "<<name<<": unhandled exception in sent operation." << endlog();
     if(taskc)
         taskc->exception();
 }
Example #6
0
bool Logger::unreportComponent( const std::string& component ) {
    TaskContext* comp = this->getPeer(component);
    if (!comp)
    {
        log(Error) << "no such component " << component << endlog();
        return false;
    }

    Ports ports   = comp->ports()->getPorts();
    for (Ports::iterator it = ports.begin(); it != ports.end() ; ++it) {
        this->unreportPort(component, (*it)->getName());
    }
    return true;
}
Example #7
0
bool Logger::reportComponent( const std::string& component ) {
    // Users may add own data sources, so avoid duplicates
    //std::vector<std::string> sources                = comp->data()->getNames();
    TaskContext* comp = this->getPeer(component);
    if ( !comp )
    {
        log(Error) << "no such component " << component << endlog();
        return false;
    }

    Ports ports   = comp->ports()->getPorts();
    for (Ports::iterator it = ports.begin(); it != ports.end() ; ++it)
        this->reportPort( component, (*it)->getName() );
    return true;
}
void
CorbaMQueueIPCTest::setUp()
{
    // setup DataPorts: we write into mw1, the server roundtrips it to mr1
    mr1 = new InputPort<double>("mr");
    mw1 = new OutputPort<double>("mw");

    tc =  new TaskContext( "root" );
    tc->ports()->addEventPort( *mr1, boost::bind(&CorbaMQueueIPCTest::new_data_listener, this, _1) );
    tc->ports()->addPort( *mw1 );
    tc->start();

    ts2 = ts = 0;
    tp2 = tp = 0;
}
Example #9
0
// report a specific connection.
bool Logger::reportPort(const std::string& component, const std::string& port ) {
    TaskContext* comp = this->getPeer(component);
    if ( !comp )
    {
        log(Error) << "no such component " << component << endlog();
        return false;
    }

    RTT::base::OutputPortInterface* writer = dynamic_cast<RTT::base::OutputPortInterface*>(comp->ports()->getPort(port));
    if ( !writer )
    {
        log(Error) << "component " << component << " does not have a port named " << port << ", or it is a read port" << endlog();
        return false;
    }

    
    std::string portname(component + "." + port);
    RTT::base::PortInterface *pi = ports()->getPort(portname);
    
    if(pi) // we are already reporting this port
    {
        log(Info) << "port " << port << " of component " << component << " is already logged" << endlog();
        return true;
    }

    // Create the corresponding read port
    RTT::base::InputPortInterface* reader = static_cast<RTT::base::InputPortInterface*>(writer->antiClone());
    reader->setName(portname);
    writer->createBufferConnection(*reader, 25);

    return addLoggingPort(reader, portname);
}
void TaskContextListBoxModel::ItemComponent::refresh (TaskContext& context)
{
	nameLabel.setText (context.getTask().getName(), dontSendNotification);

	TaskContext::TaskState state = context.getState();

	if (state == TaskContext::taskRunning)
	{
		setProgressBarVisible(true);
	}
	else
	{
		setStateMessage (context.getStateDescription());
	}

	if (stateLabel != nullptr)
	{
		stateLabel->toFront (false);
	}
	resized ();
	repaint ();
}
    // Exactly the same as th reportPort from the Reporter component
    bool ImageDisplayComponent::addDisplayPort(std::string& component, std::string& port)
    {

        Logger::In in("ImageDisplayComponent");
        TaskContext* comp = this->getPeer(component);
        if ( !comp ) {
            log(Error) << "Could not display Component " << component <<" : no such peer."<<endlog();
            return false;
        }
        PortInterface* porti   = comp->ports()->getPort(port);
        if ( !porti ) {
            log(Error) << "Could not display Port " << port
                       <<" : no such port on Component "<<component<<"."<<endlog();
            return false;
        }
        if ( porti->connected() ) {
            this->addDisplaySource( component + "." + port, "Port", porti->connection()->getDataSource() );
            log(Info) << "Reporting port " << port <<" : ok."<<endlog();
        } else {
            // create new port temporarily
            // this port is only created with the purpose of
            // creating a connection object.
            PortInterface* ourport = porti->antiClone();
            assert(ourport);

            ConnectionInterface::shared_ptr ci = porti->createConnection( ourport );
            if ( !ci )
                ci = ourport->createConnection( porti );
            if ( !ci )
                return false;
            ci->connect();

            delete ourport;
            this->addDisplaySource( component + "." + porti->getName(), "Port", ci->getDataSource() );
            log(Info) << "Created connection for port " << porti->getName()<<" : ok."<<endlog();
        }
        return true;

    }
Example #12
0
void
CorbaTest::setUp()
{
    // connect DataPorts
    mi = new InputPort<double>("mi");
    mo = new OutputPort<double>("mo");

    tc =  new TaskContext( "root" );
    tc->ports()->addPort( *mi );
    tc->ports()->addPort( *mo );

    t2 = 0;
    ts2 = ts = 0;
    tp2 = tp = 0;
    wait = cbcount = 0;
    is_calling = false, is_sending = false;

    addOperation("callBackPeer", &CorbaTest::callBackPeer, this,ClientThread);
    addOperation("callBackPeerOwn", &CorbaTest::callBackPeer, this,OwnThread);
}
void TaskThreadWithProgressWindow::taskStatusMessageChanged (TaskContext& context)
{
	setStatusMessage (context.getTask().getStatusMessage());
}
Example #14
0
    int StatementProcessor::execute(const std::string& comm)
    {
        Logger::In in("StatementProcessor");
        TaskContext* taskcontext = d->tc;

        // Minor hack : also check if it was an attribute of current TC, for example,
        // if both the object and attribute with that name exist. the if
        // statement after this one would return and not give the expr parser
        // time to evaluate 'comm'.
        if ( taskcontext->provides()->getValue( comm ) ) {
                d->printResult( taskcontext->provides()->getValue( comm )->getDataSource().get(), true );
                return 0;
        }

        Parser _parser;

        Logger::log() <<Logger::Debug << "Trying ValueChange...";
        try {
            // Check if it was a method or datasource :
            DataSourceBase::shared_ptr ds = _parser.parseValueChange( comm, taskcontext );
            // methods and DS'es are processed immediately.
            if ( ds.get() != 0 ) {
                Logger::log() << "ok" << Logger::endl;
                d->printResult( ds.get(), false );
                return 0; // done here
            } else
                Logger::log() <<Logger::Debug << "no"<<Logger::endl;
        } catch ( fatal_semantic_parse_exception& pe ) { // incorr args, ...
            // way to fatal,  must be reported immediately
            Logger::log() << Logger::Debug << "fatal_semantic_parse_exception: ";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( syntactic_parse_exception& pe ) { // wrong content after = sign etc..
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "syntactic_parse_exception: ";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( parse_exception_parser_fail &pe )
            {
                // ignore, try next parser
                Logger::log() << Logger::Debug << "Ignoring ValueChange exception :"<<Logger::nl;
                Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        } catch ( parse_exception& pe ) {
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        }
        Logger::log() << Logger::Debug << "Trying Expression..."<<Logger::nl;
        try {
            // Check if it was a method or datasource :
            DataSourceBase::shared_ptr ds = _parser.parseExpression( comm, taskcontext );
            // methods and DS'es are processed immediately.
            if ( ds.get() != 0 ) {
                d->printResult( ds.get(), true );
                return 0; // done here
            } else
                Logger::log() << Logger::Error << "returned zero !"<<Logger::nl;
        } catch ( syntactic_parse_exception& pe ) { // missing brace etc
            // syntactic errors must be reported immediately
            Logger::log() << Logger::Error << "syntactic_parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( fatal_semantic_parse_exception& pe ) { // incorr args, ...
            // way to fatal,  must be reported immediately
            Logger::log() << Logger::Error << "fatal_semantic_parse_exception :";
            Logger::log() << Logger::Error << pe.what() <<Logger::nl;
            return -1;
        } catch ( parse_exception_parser_fail &pe ) {
                // ignore, try next parser
                Logger::log() << Logger::Debug << "Ignoring Expression exception :"<<Logger::nl;
                Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        } catch ( parse_exception& pe ) {
            // ignore, try next parser
            Logger::log() << Logger::Debug << "Ignoring Expression parse_exception :"<<Logger::nl;
            Logger::log() << Logger::Debug << pe.what() <<Logger::nl;
        }
        return -1;
    }
Example #15
0
void FetchEngine::realFetch(IBucket *bucket, int fetchMax)
{
  int n2Fetched=fetchMax > 0 ? fetchMax : FetchWidth;
  maxBB = BB4Cycle; // Reset the max number of BB to fetch in this cycle (decreased in processBranch)

  // This method only can be called once per cycle or the restriction of the
  // BB4Cycle would not enforced
  I(pid>=0);
  I(maxBB>0);
  I(bucket->empty());
  
  I(missInstID==0);

  Pid_t myPid = flow.currentPid();
#ifdef TASKSCALAR
  TaskContext *tc = TaskContext::getTaskContext(myPid);
  I(tc);
  GLVID *lvid = gms->findCreateLVID(tc->getVersion());
  if (lvid==0) {
    // Not enough LVIDs. Stall fetch
    I(missInstID==0);
    nDelayInst2.add(n2Fetched);
    return;
  }
  HVersion *lvidVersion = tc->getVersion(); // no duplicate
#endif

  
  do {
    nGradInsts++; // Before executePC because it can trigger a context switch

    DInst *dinst = flow.executePC();
    if (dinst == 0)
      break;

    // If we are stalled, then this instruction will issue again so we do not
    // want to count this one
#if (defined TM)
    if(transGCM->checkStall(myPid))
    {
        delete(dinst);
        dinst==0;
        break;
    }
    else
      tmReport->registerTransInstAbort(myPid,dinst->transType);
#endif
    
#ifdef TASKSCALAR
    dinst->setLVID(lvid, lvidVersion);
#endif //TASKSCALAR

    const Instruction *inst = dinst->getInst();

#if !(defined MIPS_EMUL)
    if (inst->isStore()) {
#if (defined TLS)
      dinst->getEpoch()->pendInstr();
      dinst->getEpoch()->execInstr();
#endif // (defined TLS)
    }
#endif // For !(defined MIPS_EMUL)

    instFetched(dinst);
    bucket->push(dinst);

#ifdef XACTION
    gproc->getXactionManager()->dinstFetch(dinst);
#endif

    n2Fetched--;
  
    bbSize++;
    fbSize++;
    if(inst->isBranch()) {
      szBB.sample(bbSize);
      bbSize=0;
      
      if (!processBranch(dinst, n2Fetched)) {
	break;
      }
    }

    }while(n2Fetched>0 && flow.currentPid()==myPid);

    
#ifdef TASKSCALAR
  if (!bucket->empty())
    lvid->garbageCollect();
#endif

  ushort tmp = FetchWidth - n2Fetched;

  totalnInst+=tmp;
  if( totalnInst >= nInst2Sim ) {
    MSG("stopSimulation at %lld (%lld)",totalnInst, nInst2Sim);
    osSim->stopSimulation();
  }

  nFetched.add(tmp);
}
void TaskContextViewComponent::paint (Graphics& g)
{
	TaskContext* handler = getTaskContext ();
	if (handler != nullptr)
	{

		String name = handler->getTask().getName();
		String msg = handler->getTask().getStatusMessage();

		// 		if (rowIsSelected)
		// 		{
		// 			g.setColour (Colours::darkgrey.withAlpha(0.3f));
		// 			g.fillAll ();
		// 		}

		g.setColour (Colours::black);
		Rectangle<int> area (0,0,getWidth(),getHeight());
		area = area.reduced (4);

		int halfHeight = getHeight()/2;
		g.drawFittedText(handler->getTask().getName(), getLocalBounds().withTrimmedBottom(halfHeight).reduced(4), Justification::centredLeft, 1);
		//g.drawFittedText(handler->getStateDescription(), getLocalBounds().withTrimmedTop(halfHeight).reduced(4), Justification::centredLeft, 1);

		switch (handler->getState())
		{
		case TaskContext::taskPending:
			{
				g.setColour (Colours::blue.withAlpha(0.2f));
				g.fillRect (area.reduced(2));
			}
			break;
		case TaskContext::taskRunning:
			{
				double prog = handler->getTask().getProgress();//getOverallProgress();
				g.setColour (Colours::hotpink.withAlpha(0.5f));
				g.fillRect (area.reduced(2).withTrimmedRight (roundDoubleToInt (area.getWidth() * (1 - prog))));
			}
			break;

		case TaskContext::taskCompleted:
			{
				g.setColour (Colours::green.withAlpha(0.5f));
				g.fillRect (area.reduced(2));
			}
			break;

		case TaskContext::taskAborted:
			{
				g.setColour (Colours::red.withAlpha(0.5f));
				g.fillRect (area.reduced(2));
			}
			break;

		case TaskContext::taskStarting:
			{
				g.setColour (Colours::brown.withAlpha(0.5f));
				g.fillRect (area.reduced(2));
			}
			break;

		default:;
			break;
		}



	}
}
void TaskContextListBoxModel::ItemComponent::taskProgressChanged (TaskContext& context)
{
	progress = context.getTask().getProgress();
}
void TaskThreadWithProgressWindow::taskProgressChanged (TaskContext& context)
{
	setProgress (context.getTask().getProgress ());
}