예제 #1
0
/* Initialize for programs not started with os_procCreate*/
void
os_procInitialize()
{
    os_procContextData process_procContextData;
    os_int32 status = os_resultSuccess;
    os_int32 taskid;

    if ( readTLSVarSelf(procContextData) == NULL) {
        taskid = taskIdSelf();
        process_procContextData = (os_procContextData )os_malloc((size_t)OS_SIZEOF(os_procContextData));
        if (process_procContextData == (os_procContextData) NULL) {
            OS_REPORT(OS_WARNING, "os_procCreate", 1,
                        "malloc failed with error %d (%s)",
                        os_getErrno(), taskName(taskIdSelf()));
        } else {
            os_procInit(process_procContextData, taskName((int)taskid), "program" , "none");
            os_procSetTaskId(process_procContextData, (int)taskid);
            process_procContextData->procAttrPrio = VXWORKS_PRIORITY_DEFAULT;
            /* create & set context variable for the task */
            status = os_procAddTaskVar((int)taskid, "none", process_procContextData, 0);
            if (status == os_resultSuccess) {
                status = os_threadNew(process_procContextData->procName);
            } else {
                printf("os_procApplAddContext os_threadNew ERROR\n");
            }
            process_procContextData->procStartWithProcCreate = 1; /* not started with procCreate*/
       }
    }

}
예제 #2
0
int main(void)
{
    uart_init();
    uartBuf = calloc(1, 20 * sizeof(char));
    os_threadConfig_t conf = { .name = "main", .threadCallback = mainThread,
            .threadArgs = NULL, .stackSize = STACK_SIZE_DEFAULT, .priority =
                    THREAD_PRIO_LOW };

    os_timerConfig_t timerConf = { .name = "task1", .period = 10, .oneShot =
            false, .callback = timerTask };
    os_timerTaskNew(&timerConf, 0);
    threadHandle = os_threadNew(&conf);
    os_startScheduler();
    while (1)
        ;   // never reached
    free(uartBuf);
    return 0;
}
예제 #3
0
static os_result
os_procWrapper(
    os_procContextData process_procContextData,
    char *executable_file,
    os_int32 *startRoutine,
    const char *arguments,
    TASK_ID parent,
    os_sem_t *blockParent)
{
    int taskid;
    os_int32 status = os_resultSuccess;
    os_int32 routine_status = -1;
    os_int32 (*this_startRoutine)(const char *);

#if ( _WRS_VXWORKS_MAJOR > 6 ) || ( _WRS_VXWORKS_MAJOR == 6 && _WRS_VXWORKS_MINOR > 8 )
      envPrivateCreate(taskIdSelf(), parent);
      os_sem_post(blockParent);
#endif

    taskid = taskIdSelf();
    os_procSetTaskId(process_procContextData, taskid);
    /* create & set context variable for the task */
    status = os_procAddTaskVar(taskid, executable_file, process_procContextData, 0);
    if (status == os_resultSuccess) {
        status = os_threadNew(process_procContextData->procName);
    }
    if (status == os_resultSuccess) {
        this_startRoutine = (os_int32 *)startRoutine;
        routine_status = this_startRoutine(arguments);
        os_procLocalExit(OS_EXIT_SUCCESS);
        os_threadDeleteTaskVar(taskid, os_threadIdSelf());
        os_procDeleteTaskVar(taskid, executable_file, process_procContextData);
        os_procSetExitValue(process_procContextData, routine_status);
    }

#if ( _WRS_VXWORKS_MAJOR > 6 ) || ( _WRS_VXWORKS_MAJOR > 6 && _WRS_VXWORKS_MINOR > 8 )
      envPrivateDestroy(taskIdSelf());
#endif
    return (status);
}