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(); } }
void Server::addTask(AbsRTTask &task, const string ¶ms) { DBGENTER(_SERVER_DBG_LEV); task.setKernel(this); tasks.push_back(&task); DBGPRINT_2("Calling sched->addTask, with params = ", params); sched_->addTask(&task, params); }
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); }
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); }
void RTKernel::addTask(AbsRTTask &t, const string ¶ms) { t.setKernel(this); _handled.push_back(&t); _sched->addTask(&t, params); }