Beispiel #1
0
int
RSIM_Simulator::main_loop()
{
    RSIM_Process *process = get_process();
    RSIM_Thread *thread = process->get_main_thread();

    /* The simulator's main thread is executed by the calling thread because the simulator's main thread must be a thread group
     * leader. */
    bool cb_process_status = process->get_callbacks().call_process_callbacks(RSIM_Callbacks::BEFORE, process,
                                                                             RSIM_Callbacks::ProcessCallback::START,
                                                                             true);

    // The process' main thread has already been created and initialized but has not started running yet.
    thread->start();
    thread->waitForState(RSIM_Thread::TERMINATED);

    process->get_callbacks().call_process_callbacks(RSIM_Callbacks::AFTER, process,
                                                    RSIM_Callbacks::ProcessCallback::FINISH,
                                                    cb_process_status);

    return process->get_termination_status();
}