示例#1
0
文件: server.cpp 项目: glipari/rtlib
    void Server::onDispatch(Event *e)
    {
        DBGENTER(_SERVER_DBG_LEV);

        AbsRTTask *newExe = sched_->getFirst();

        DBGPRINT("Current situation");
        DBGPRINT_2("newExe: ", taskname(newExe));
        DBGPRINT_2("currExe_: ", taskname(currExe_));
        
        if (newExe != currExe_) {
            if (currExe_ != NULL) currExe_->deschedule();
            currExe_ = newExe;
            if (newExe != NULL) newExe->schedule();
            //sched_->notify(newExe);
        }

        DBGPRINT_2("Now Running: ", taskname(newExe));

        if (currExe_ == NULL) {
            sched_->notify(NULL);
            executing_releasing();
            kernel->suspend(this);
            kernel->dispatch();
        }
    }
示例#2
0
文件: server.cpp 项目: glipari/rtlib
 void Server::addTask(AbsRTTask &task, const string &params)
 {
     DBGENTER(_SERVER_DBG_LEV);
     task.setKernel(this);
     tasks.push_back(&task);
     DBGPRINT_2("Calling sched->addTask, with params = ", params);
     sched_->addTask(&task, params);
 }
示例#3
0
    void MRTKernel::onEndDispatchMulti(EndDispatchMultiEvt* e)
    {
        // performs the "real" context switch
        DBGENTER(_KERNEL_DBG_LEV);

        AbsRTTask *st = e->getTask();
        CPU *p = e->getCPU();

        _m_currExe[p] = st;

        DBGPRINT_2("CPU: ", p);
        DBGPRINT_2("Task: ", taskname(st));
        
        // st could be null (because of an idling processor)
        if (st) st->schedule();

	_isContextSwitching[p] = false;
        _sched->notify(st);
    }
示例#4
0
    void MRTKernel::onBeginDispatchMulti(BeginDispatchMultiEvt* e)
    {
        DBGENTER(_KERNEL_DBG_LEV);

        // if necessary, deschedule the task.
        CPU * p = e->getCPU();
        AbsRTTask *dt  = _m_currExe[p];
        AbsRTTask *st  = NULL;

        if ( dt != NULL ) {
            _m_oldExe[dt] = p;
            _m_currExe[p] = NULL;
            _m_dispatched[dt] = NULL;
            dt->deschedule();
        }

        // select the first non dispatched task in the queue
        int i = 0;
        while ((st = _sched->getTaskN(i)) != NULL) 
            if (_m_dispatched[st] == NULL) break;
            else i++;

        if (st == NULL) {
            DBGPRINT("Nothing to schedule, finishing");
        }

        DBGPRINT_4("Scheduling task ", taskname(st), " on cpu ", p);
        
        if (st) _m_dispatched[st] = p;
        _endEvt[p]->setTask(st);
        _isContextSwitching[p] = true;
        Tick overhead (_contextSwitchDelay);
        if (st != NULL && _m_oldExe[st] != p && _m_oldExe[st] != NULL) 
            overhead += _migrationDelay;
        _endEvt[p]->post(SIMUL.getTime() + overhead);        
    }
示例#5
0
 void RTKernel::addTask(AbsRTTask &t, const string &params) 
 { 
     t.setKernel(this);
     _handled.push_back(&t); 
     _sched->addTask(&t, params);
 }