示例#1
0
/*
 *  ======== Lock_init ========
 */
Void Lock_init(Void)
{
    if (curInit == FALSE) {
        curInit = TRUE;
        Lock_system = Lock_create(NULL);
    }

    Global_atexit((Fxn)cleanup);
}
/*
 *  ======== Memory_init ========
 */
Bool Memory_init(Void)
{
    Registry_Result   result;

    /*
     *  No need to reference count for Registry_addModule(), since there
     *  is no way to remove the module.
     */
    if (regInit == 0) {
        /* Register this module for logging */
        result = Registry_addModule(&ti_sdo_ce_osal_Memory_desc,
                Memory_MODNAME);
        Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);

        if (result == Registry_SUCCESS) {
            /* Set the diags mask to the CE default */
            CESettings_init();
            CESettings_setDiags(Memory_MODNAME);
        }
        regInit = 1;
    }

    if (curInit != TRUE) {
        curInit = TRUE;
        moduleLock = Lock_create(NULL);
        if (moduleLock == NULL) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: could not create pthread mutex.");
            assert(FALSE);
        }

        if (CMEM_init() == -1) {
            Log_print0(Diags_USER7, "[+7] Memory_init> "
                    "ERROR: Failed to initialize CMEM");
        }
        else {
            cmemInitialized = TRUE;
        }

        Global_atexit((Fxn)cleanup);
    }

    return (cmemInitialized);
}
示例#3
0
/*
 *  ======== Processor_init ========
 */
Void Processor_init(Void)
{
    if (curInit != TRUE) {
        curInit = TRUE;

        GT_create(&curTrace, Processor_GTNAME);

        /* Semaphore with count 0, will be posted when a command is present */
        dcmd.cmdPresent = Sem_create(CMDKEY, 0);

        /* Semaphore with count 0, will be posted when reply is ready */
        dcmd.replyPresent = Sem_create(REPLYKEY, 0);

        /*
         *  Create lock to allow only one thread at a time to send command
         *  to the daemon.
         */
        dcmd.gate = Lock_create(NULL);

        if ((dcmd.cmdPresent == NULL) || (dcmd.replyPresent == NULL) ||
                (dcmd.gate == NULL)) {
            // TODO: Shouldn't we abort?
            GT_0trace(curTrace, GT_7CLASS, "Processor_init> ERROR: cannot"
                " create semaphores or lock\n");
        }

        if ((dcmd.dproc = Thread_create((Fxn)daemon, NULL)) == NULL) {
            GT_0trace(curTrace, GT_7CLASS, "Processor_init> "
                "ERROR: cannot create DSP daemon\n");
        }

        Power_init();

        Global_atexit((Fxn)cleanup);
    }
}