Exemplo n.º 1
0
//
// Main program for standalone version of asim, the Asim "classic" controller.
//
int CONTROLLER_CLASS::main(INT32 argc, char *argv[], char *envp[])
{
    // force line buffering for reasonable synchronization of stderr and
    // stdout in batch runs
    setlinebuf(stdout);
    setlinebuf(stderr);

    // shared buffers between C-style stdio and C++-style streamio
    cin.sync_with_stdio();
    cout.sync_with_stdio();
    cerr.sync_with_stdio();

    theController.PrintInfo();

    // Initialize awb
    //
    AWB_Initialize();

    // Initialize for stack dumping on segfaults
    StackDumpInit(argv[0]);

    // 
    // Initialize memory tracking routine
    StackTraceInit(argv[0]); 

    //
    // Partition arguments for awb, system, and feeder.
    theController.PartitionArgs(argc, argv);

    //
    // Initialize by calling the controller,
    // it will initialize system and feeder.
    if (!theController.CMD_Init(fdArgc, fdArgv, sysArgc, sysArgv, envp)) {
        cout << "Performance model failed to initialize" << endl;
        return(1);
    }

    //
    // Parse awb's arguments.
    if (!theController.ParseEvents(awbArgc, awbArgv)) {
        theController.Usage(argv[0], stdout);
        return(1);
    }

    //
    // Start the awb workbench...    
    AWB_Activate();

    //
    // Let the system execute until our scheduled options are complete.
    theController.CMD_SchedulerLoop();

    return(0);
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
  struct sigaction sact;

  StackTraceInit(argv[0], -1);

  sigemptyset(&sact.sa_mask);
  sact.sa_flags = 0;
  sact.sa_handler = CrashHandler;
  sigaction(SIGSEGV, &sact, NULL);
  sigaction(SIGBUS, &sact, NULL);

  Crash();
  return EXIT_SUCCESS;
}
Exemplo n.º 3
0
U_THREAD_PROC(pping_client_thread_proc, arg)
{
    if (uThreadBlockAllSignals(NULL) != 0)
        d_printf1("Failed to block signals for pping_client_thread_proc");

    pping_client *ppc = (pping_client*)arg;
    char c = PPING_KEEP_ALIVE_MSG;

    while (true)
    {
        if (ppc->stop_keep_alive) return 0;

        int res = usend(ppc->sock, &c, sizeof(c), NULL);

        if (res != sizeof(c) && !ppc->stop_keep_alive) {
            sedna_soft_fault("SEDNA GOVERNOR is down", ppc->component);
        }

        /* se_stop -hard has been called? */
        if(ppc->signaled_flag    != NULL  &&
                GOV_HEADER_GLOBAL_PTR != NULL  &&
                GOV_HEADER_GLOBAL_PTR -> is_server_stop == SE_STOP_HARD)
        {
            *(ppc->signaled_flag) = true;
        }

        UUnnamedSemaphoreDownTimeout(&(ppc->sem), 1000, NULL);

        if(ppc->timeout)
        {

            if (!ppc->counter && !ppc->reset_flag) {
                *(ppc->signaled_flag) = true;
                ppc->counter = ppc->timeout;
            }

            if(ppc->reset_flag)
            {
                ppc->counter = ppc->timeout;
                if(ppc->signaled_flag) *(ppc->signaled_flag) = false;
                ppc->reset_flag = false;
            }

            (ppc->counter)--;
        }
#if (defined(EL_DEBUG) && (EL_DEBUG == 1))
#define SENDVAR(v) if (usend(ppc->sock, (char*)&v, sizeof(v), NULL) != sizeof(v)) continue;
#ifdef _WIN32
        if (ppc->exceptPtrs)
        {
            //TODO: do something if usend/urecv fails or get wrong msg
            char cc = PPING_PROC_EXCEPTION_MSG;
            DWORD proc_id = GetCurrentProcessId();

            if (usend(ppc->sock, &cc, sizeof(cc), NULL) != sizeof(cc))
            {
                ppc->exceptPtrs = NULL;
                continue;
            }

            SENDVAR(proc_id)
            SENDVAR(ppc->component);
            SENDVAR(ppc->except_thread_id);
            SENDVAR(ppc->exceptPtrs);

            if (urecv(ppc->sock, &cc, sizeof(cc), NULL) != sizeof(cc))
            {
                ppc->exceptPtrs = NULL;
                continue;
            }
            if (cc != PPING_PROC_EXCEPTION_MSG)
            {
                ppc->exceptPtrs = NULL;
                continue;
            }

            if (ppc->stacktrace_fh != U_INVALID_FD)
            {
                if (StackTraceInit() != 0)
                {
                    StackTraceWriteFd(ppc->exceptPtrs->ContextRecord, (intptr_t)ppc->stacktrace_fh, 9999, 0);

                    StackTraceDeinit();
                }
                uCloseFile(ppc->stacktrace_fh, NULL);
            }


            ppc->exceptPtrs = NULL;
        }
#endif
#undef SENDVAR
#endif
    }
    return 0;
}