Exemple #1
0
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;
}
StatusType TerminateTask(void)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status: no return to Calllevel.
**      Extended-Status:
**              – E_OS_RESOURCE – the task still occupies resources.
**              – E_OS_CALLEVEL – a call at the interrupt level.
**
*/
    SAVE_SERVICE_CONTEXT(OSServiceId_TerminateTask, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    DISABLE_ALL_OS_INTERRUPTS();
    OS_TASK_DECR_ACTIVATIONS(OsCurrentTID);
    OsTask_Suspend(OsCurrentTID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (OsCurrentTCB->Activations > 0) {  /* ???  */
        OS_TASK_CLEAR_ALL_EVENTS(OsCurrentTID);
        OsTask_Init(OsCurrentTID, TRUE);
        OsTask_Ready(OsCurrentTID);
    }

#endif

    OS_UNLOCK_INTERNAL_RESOURCE();
    ENABLE_ALL_OS_INTERRUPTS();

    OsExec_StartHighestReadyTask();

    CLEAR_SERVICE_CONTEXT();
    return E_OK; /* never reached */
}
Exemple #4
0
StatusType TerminateTask(void)
#endif /* KOS_MEMORY_MAPPING */
{
/*
**      Standard-Status: no return to Calllevel.
**      Extended-Status:
**              – E_OS_RESOURCE – the task still occupies resources.
**              – E_OS_CALLEVEL – a call at the interrupt level.
**
*/
    Os_SaveServiceContext(OSServiceId_TerminateTask, NULL, NULL, NULL);
    ASSERT_VALID_CALLEVEL(OS_CL_TASK);
    ASSERT_INTERRUPTS_ENABLED_AT_TASK_LEVEL();
    ASSERT_CURR_TASK_OCCUPIES_NO_RESOURCES();

    OsPort_DisableAllOsInterrupts();
    OsTask_DecrActivations(Os_CurrentTID);
    OsTask_Suspend(Os_CurrentTID);

#if defined(OS_BCC2) || defined(OS_ECC2)

    if (Os_CurrentTCB->Activations > 0) {  /* ???  */
        OsTask_ClearAllEvents(Os_CurrentTID);
        OsTask_Init(Os_CurrentTID, TRUE);
        OsTask_Ready(Os_CurrentTID);
    }

#endif

    OsTask_UnlockInternalResource();
    OsPort_EnableAllOsInterrupts();

    OsExec_StartHighestReadyTask();

    Os_ClearServiceContext();
    return E_OK; /* never reached */
}