StatusType OsTask_Activate(TaskType TaskID) #endif /* KOS_MEMORY_MAPPING */ { SAVE_SERVICE_CONTEXT(OSServiceId_ActivateTask, TaskID, NULL, NULL); ASSERT_VALID_TASKID(TaskID); ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2); WARN_IF_TO_MANY_ACTIVATIONS(TaskID); DISABLE_ALL_OS_INTERRUPTS(); OS_TASK_INCR_ACTIVATIONS(TaskID); #if defined(OS_BCC2) || defined(OS_ECC2) if (OS_IS_TASK_SUSPENDED(TaskID)) { #endif OS_TASK_CLEAR_ALL_EVENTS(TaskID); OsTask_Init(TaskID, FALSE); OsTask_Ready(TaskID); #if defined(OS_BCC2) || defined(OS_ECC2) } #endif ENABLE_ALL_OS_INTERRUPTS(); CLEAR_SERVICE_CONTEXT(); return E_OK; }
StatusType OsTask_Activate(TaskType TaskID) #endif /* KOS_MEMORY_MAPPING */ { Os_SaveServiceContext(OSServiceId_ActivateTask, TaskID, NULL, NULL); ASSERT_VALID_TASKID(TaskID); ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); ASSERT_VALID_CALLEVEL(OS_CL_TASK | OS_CL_ISR2); WARN_IF_TO_MANY_ACTIVATIONS(TaskID); OsPort_DisableAllOsInterrupts(); OsTask_IncrActivations(TaskID); #if defined(OS_BCC2) || defined(OS_ECC2) if (OsTask_IsSuspended(TaskID)) { #endif OsTask_ClearAllEvents(TaskID); OsTask_Init(TaskID, FALSE); OsTask_Ready(TaskID); #if defined(OS_BCC2) || defined(OS_ECC2) } #endif OsPort_EnableAllOsInterrupts(); Os_ClearServiceContext(); return E_OK; }
StatusType ChainTask(TaskType TaskID) #endif /* KOS_MEMORY_MAPPING */ { Os_SaveServiceContext(OSServiceId_ChainTask, TaskID, NULL, NULL); ASSERT_VALID_TASKID(TaskID); ASSERT_VALID_CALLEVEL(OS_CL_TASK); ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES(); if (TaskID != Os_CurrentTID) { WARN_IF_TO_MANY_ACTIVATIONS(TaskID); } OsPort_DisableAllOsInterrupts(); OsTask_UnlockInternalResource(); OsTask_DecrActivations(Os_CurrentTID); OsTask_Suspend(Os_CurrentTID); OsTask_IncrActivations(TaskID); OsTask_ClearAllEvents(TaskID); OsTask_Init(TaskID, ((TaskID == Os_CurrentTID) ? TRUE : FALSE)); OsTask_Ready(TaskID); ASSERT(OS_TCB[Os_CurrentTID].State == SUSPENDED); OsPort_EnableAllOsInterrupts(); OsExec_StartHighestReadyTask(); Os_ClearServiceContext(); return E_OK; }
StatusType ChainTask(TaskType TaskID) #endif /* KOS_MEMORY_MAPPING */ { /* ** Terminates running Task and activates another, enforces Rescheduling. ** ** Standard-Status: ** – No return to call level. ** – E_OS_LIMIT – too many activations of <TaskID>. ** Extended-Status: ** – E_OS_ID – the task identifier is invalid. ** – E_OS_RESOURCE – the calling task still occupies resources. ** – E_OS_CALLEVEL – a call at the interrupt level. */ SAVE_SERVICE_CONTEXT(OSServiceId_ChainTask, TaskID, NULL, NULL); ASSERT_VALID_TASKID(TaskID); ASSERT_VALID_CALLEVEL(OS_CL_TASK); ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL(); ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES(); if (TaskID != OsCurrentTID) { WARN_IF_TO_MANY_ACTIVATIONS(TaskID); } DISABLE_ALL_OS_INTERRUPTS(); OS_UNLOCK_INTERNAL_RESOURCE(); OS_TASK_DECR_ACTIVATIONS(OsCurrentTID); OsTask_Suspend(OsCurrentTID); OS_TASK_INCR_ACTIVATIONS(TaskID); OS_TASK_CLEAR_ALL_EVENTS(TaskID); OsTask_Init(TaskID, ((TaskID == OsCurrentTID) ? TRUE : FALSE)); OsTask_Ready(TaskID); ASSERT(OS_TCB[OsCurrentTID].State == SUSPENDED); ENABLE_ALL_OS_INTERRUPTS(); OsExec_StartHighestReadyTask(); CLEAR_SERVICE_CONTEXT(); return E_OK; }