Exemplo n.º 1
0
xme_status_t
xme_core_exec_dispatcher_initializeTask
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId
)
{
    /* Look up for a task descriptor */
    xme_core_exec_taskDescriptor_t* thisTask = NULL;

    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): > [%d|%d] dispatcher_initializeTask()\n",
            componentId,
            functionId);
    XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask),
        XME_STATUS_NOT_FOUND);

    /* Move the task to running state */
    XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_setTaskState(componentId, functionId, XME_CORE_EXEC_FUNCTION_STATE_RUNNING),
        XME_STATUS_INTERNAL_ERROR);

    /* Execution manager initially owns the mutex allowing the task to execute */
    xme_core_exec_lockMutex("S/t",thisTask->waitLock, componentId, functionId);

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): < [%d|%d] dispatcher_initializeTask()\n",
            componentId,
            functionId);

    return XME_STATUS_SUCCESS;
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_dispatcher_setRunnable
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_hal_sched_taskHandle_t handle
)
{
    xme_core_exec_taskDescriptor_t* taskRecord;
    xme_status_t status;

    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_CHECK(XME_STATUS_SUCCESS == (status=xme_core_exec_descriptorTable_getTaskDescriptor(componentId,
                                                                                    functionId,
                                                                                    &taskRecord)),
        status);

    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);

    taskRecord->handle = handle;

    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);
    return XME_STATUS_SUCCESS;
}
Exemplo n.º 3
0
uint32_t
xme_core_exec_dispatcher_getCycleCount( void )
{
    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    return dispatcherCycleCounter;
}
Exemplo n.º 4
0
xme_status_t
xme_core_exec_dispatcher_incCycleCount( void )
{
    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;
    dispatcherCycleCounter++;
    return XME_STATUS_SUCCESS;
}
Exemplo n.º 5
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_descriptorTable_getTaskDescriptor
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_core_exec_taskDescriptor_t** taskDesc
)
{
        xme_core_exec_taskDescriptor_t* schedRecord = NULL;
        bool found=false;

        /* We only deal with an initialized component */
        if (!xme_core_exec_isInitialized())
                return XME_STATUS_UNEXPECTED;

        XME_LOG(XME_LOG_DEBUG,
            MODULE_ACRONYM "getTaskDescriptor(): (%d:%d)\n", componentId, functionId);

        xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
        {
            XME_HAL_TABLE_ITERATE_BEGIN(taskDescriptorsTable, uint32_t, i, xme_core_exec_taskDescriptor_t, schedRecord1);
            {
                if((schedRecord1->wrapper->componentId == componentId) && (schedRecord1->wrapper->functionId == functionId))
                {
                    schedRecord=schedRecord1;
                    found=true;
                    break;
                }
            }
            XME_HAL_TABLE_ITERATE_END();
        }
        xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);

        XME_LOG(XME_LOG_DEBUG,
            MODULE_ACRONYM "/getTaskDescriptor(): (%d:%d)\n", componentId, functionId);

        if(found)
        {
            *taskDesc = schedRecord;
            return XME_STATUS_SUCCESS;
        }
        else
        {
            XME_LOG(XME_LOG_VERBOSE,
                MODULE_ACRONYM "[%d|%d] not found in task table!\n", componentId, functionId);
            *taskDesc = NULL;
            return XME_STATUS_NOT_FOUND;
        }
}
Exemplo n.º 6
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_dispatcher_createFunctionExecutionUnit
(
    xme_core_exec_functionDescriptor_t* functionDescriptor,
    bool eventTriggeredBehavior
)
{
    xme_core_exec_taskDescriptor_t* taskRecord = NULL;

    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "> dispatcher_createFunctionExecutionUnit()\n");

    XME_CHECK_MSG( true == xme_core_exec_isValidFunctionDescriptor(functionDescriptor),
        XME_STATUS_INVALID_PARAMETER,
        XME_LOG_WARNING,
        "error adding a new task descriptor to the descriptor table.\n");

    XME_CHECK_MSG( XME_STATUS_NOT_FOUND == xme_core_exec_descriptorTable_getTaskDescriptor(
                    functionDescriptor->componentId, functionDescriptor->functionId, &taskRecord),
               XME_STATUS_ALREADY_EXIST,
               XME_LOG_WARNING,
               MODULE_ACRONYM "error: the task descriptor exists for [%d|%d]\n",
               functionDescriptor->componentId, functionDescriptor->functionId);

    XME_CHECK_MSG( XME_STATUS_SUCCESS == xme_core_exec_dispatcher_addNewTaskDescriptor(&taskRecord),
        XME_STATUS_INTERNAL_ERROR,
        XME_LOG_WARNING,
        "error adding a new task descriptor to the descriptor table.\n");

    XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_initializeTaskDescriptor(taskRecord, functionDescriptor, eventTriggeredBehavior),
        XME_STATUS_INTERNAL_ERROR,
        XME_LOG_WARNING,
        "error adding a new task descriptor to the descriptor table.\n");

    XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_startRunnable(functionDescriptor),
        XME_STATUS_INTERNAL_ERROR,
        XME_LOG_WARNING,
        "error starting runnable.\n");


    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "< dispatcher_createFunctionExecutionUnit()\n");
    return XME_STATUS_SUCCESS;
}
Exemplo n.º 7
0
xme_status_t
xme_core_exec_dispatcher_waitForStart
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    void** functionArguments
)
{
    xme_core_exec_taskDescriptor_t* thisTask = NULL;

    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): > dispatcher_waitForStart()\n");

    XME_CHECK_MSG(XME_STATUS_SUCCESS ==
        xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask),
        XME_STATUS_NOT_FOUND,
        XME_LOG_FATAL,
        MODULE_ACRONYM "task [%d|%d] not present in the task table!\n",
        componentId, functionId);

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): [%d|%d] waitForStart()\n",  componentId, functionId);

    XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_requestExecutionToken(thisTask),
              XME_STATUS_INTERNAL_ERROR);

    XME_LOG(XME_LOG_DEBUG,
            MODULE_ACRONYM "passing %" PRIu32 " to function [%d|%d]\n",
            (uint32_t)(uintptr_t)startData, componentId, functionId);

    if (NULL != functionArguments)
        *functionArguments = startData;

    /* XXX temporary workaround to allow smooth transition to xme_core_exec_getTaskState() */
    thisTask->wrapper->state = thisTask->state;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): < [%d|%d] dispatcher_waitForStart()\n",
        componentId, functionId);
    return XME_STATUS_SUCCESS;
}
Exemplo n.º 8
0
xme_status_t
xme_core_exec_dispatcher_executionCompleted
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId
)
{
    xme_core_exec_taskDescriptor_t* thisTask = NULL;

    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): > [%d|%d] dispatcher_executionCompleted()\n",
            componentId,
            functionId);

    /* Look up for a task descriptor */
    XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &thisTask),
        XME_STATUS_NOT_FOUND);

    /* Stop monitoring the task */
    thisTask->running = false;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "(t): [%d|%d] execution time total = %" PRIu64 "\n",
        componentId, functionId,
        xme_hal_time_getTimeInterval(&(thisTask->startTime), (bool)false));

    XME_CHECK(XME_STATUS_SUCCESS == xme_core_exec_dispatcher_returnExecutionToken(thisTask),
              XME_STATUS_INTERNAL_ERROR);

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "***************** /executionCompleted  [%d|%d] *********************\n",
        componentId,
        functionId);

    return XME_STATUS_SUCCESS;
}