bool ezTaskSystem::ExecuteTask(ezTaskPriority::Enum FirstPriority, ezTaskPriority::Enum LastPriority, ezTask* pPrioritizeThis) { ezTaskSystem::TaskData td = GetNextTask(FirstPriority, LastPriority, pPrioritizeThis); if (td.m_pTask == nullptr) return false; td.m_pTask->Run(); // notify the group, that a task is finished, which might trigger other tasks to be executed TaskHasFinished(td.m_pTask, td.m_pBelongsToGroup); return true; }
PROCESS * GetNextProcess(void) { PROCESS * temp; temp = GetNextTask(); temp->state = RUNNING; CurrentPID = temp->pid; if(temp->pid == 0) currentProcessTTY = currentTTY; else currentProcessTTY = temp->tty; last100[counter100] = CurrentPID; counter100 = (counter100 + 1) % 100; return temp; }
//Funcion que devuelve el PROCESS* siguiente a ejecutar PROCESS* GetNextProcess (void) { char* video=(char*)0xb8000; PROCESS* temp; //selecciona la tarea temp=GetNextTask(); temp->lastCalled=0; CurrentPID=temp->pid; last100[counter100]=CurrentPID; counter100=(counter100+1)%100; return temp; }
void* PosixTaskQueue::Run() { while (true) { OpTask* task = GetNextTask(); if (task) { task->Execute(); delete task; } else if(exit) break; } return NULL; }
void CScheduler::Yield (void) { while ((m_nCurrent = GetNextTask ()) == MAX_TASKS) // no task is ready { assert (m_nTasks > 0); } assert (m_nCurrent < MAX_TASKS); CTask *pNext = m_pTask[m_nCurrent]; assert (pNext != 0); if (m_pCurrent == pNext) { return; } TTaskRegisters *pOldRegs = m_pCurrent->GetRegs (); m_pCurrent = pNext; TTaskRegisters *pNewRegs = m_pCurrent->GetRegs (); assert (pOldRegs != 0); assert (pNewRegs != 0); TaskSwitch (pOldRegs, pNewRegs); }
extern StatusType Schedule ( void ) #endif { /* \req OSEK_SYS_3.4 The system service StatusType Schedule ( void ) shall ** be defined */ /* \req OSEK_SYS_3.4.4 Possible return values in Standard mode is E_OK */ StatusType ret = E_OK; TaskType nextTask; TaskType actualTask; #if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) ContextType actualContext; #endif IntSecure_Start(); /* get actual running task */ actualTask = GetRunningTask(); /* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode are E_OS ** CALLEVEL, E_OS_RESOURCE */ #if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) /* get actual context */ actualContext = GetCallingContext(); /* if called from scheduler no checks shall be performed */ if (FALSE == PerformChecks) { /* no checks shall be performed */ } else if ( ( CONTEXT_TASK != actualContext ) && ( CONTEXT_SYS != actualContext ) ) { /* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode ** are E_OS_CALLEVEL, E_OS_RESOURCE */ ret = E_OS_CALLEVEL; } else if ( ( INVALID_TASK != actualTask ) && ( CONTEXT_TASK == actualContext ) ) { if ( TasksVar[actualTask].Resources != 0 ) { /* \req OSEK_SYS_3.3.5 Extra possible return values in Extended mode ** are E_OS_CALLEVEL, E_OS_RESOURCE */ ret = E_OS_RESOURCE; } } else { /* nothing to check Runngin Task is invalid */ } if (ret == E_OK) #endif { /* get next task */ nextTask = GetNextTask(); /* while until one or boths are not more invalid tasks */ while ( ( actualTask == INVALID_TASK ) && ( nextTask == INVALID_TASK) ) { IntSecure_End(); /* macro used to indicate the processor that we are in idle time */ osekpause(); IntSecure_Start(); /* get next task */ nextTask = GetNextTask(); }; /* if the actual task is invalid */ if ( actualTask == INVALID_TASK ) { /* set task state to running */ TasksVar[nextTask].Flags.State = TASK_ST_RUNNING; /* set as running task */ SetRunningTask(nextTask); /* set actual context task */ SetActualContext(CONTEXT_TASK); IntSecure_End(); #if (HOOK_PRETASKHOOK == OSEK_ENABLE) PreTaskHook(); #endif /* #if (HOOK_PRETASKHOOK == OSEK_ENABLE) */ /* jmp tp the next task */ JmpTask(nextTask); } else { /* check priorities */ /* \req OSEK_SYS_3.4.1 If a task with a lower or equal priority than the ** ceiling priority of the internal resource and higher priority than ** the priority of the calling task is ready */ if ( TasksConst[nextTask].StaticPriority > TasksVar[actualTask].ActualPriority ) { #if (HOOK_POSTTASKHOOK == OSEK_ENABLE) PostTaskHook(); #endif /* #if (HOOK_POSTTASKHOOK == OSEK_ENABLE) */ /* \req OSEK_SYS_3.4.1.1 the internal resource of the task shall be ** released */ ReleaseInternalResources(); /* \req OSEK_SYS_3.4.1.2 the current task is put into the ready state */ TasksVar[actualTask].Flags.State = TASK_ST_READY; /* set the new task to running */ TasksVar[nextTask].Flags.State = TASK_ST_RUNNING; /* set as running task */ SetRunningTask(nextTask); /* set actual context task */ SetActualContext(CONTEXT_TASK); IntSecure_End(); #if (HOOK_PRETASKHOOK == OSEK_ENABLE) PreTaskHook(); #endif /* #if (HOOK_PRETASKHOOK == OSEK_ENABLE) */ /* \req OSEK_SYS_3.4.1.3 its context is saved */ /* \req OSEK_SYS_3.4.1.4 and the higher-priority task is executed */ CallTask(actualTask, nextTask); } else { IntSecure_End(); /* \req OSEK_SYS_3.4.2 Otherwise the calling task is continued */ } } } #if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) else { IntSecure_End(); } #endif /* #if (ERROR_CHECKING_TYPE == ERROR_CHECKING_EXTENDED) */ #if (HOOK_ERRORHOOK == OSEK_ENABLE) /* \req OSEK_ERR_1.3-4/xx The ErrorHook hook routine shall be called if a ** system service returns a StatusType value not equal to E_OK.*/ /* \req OSEK_ERR_1.3.1-4/xx The hook routine ErrorHook is not called if a ** system service is called from the ErrorHook itself. */ if ( ( ret != E_OK ) && (ErrorHookRunning != 1)) { SetError_Api(OSServiceId_Schedule); SetError_Ret(ret); SetError_Msg("Schedule Task returns != than E_OK"); SetError_ErrorHook(); } #endif return ret; }