void QtHost::SendGPUWait(u32 cmd, u32 addr, void *data) { EmuThread_LockDraw(false); if((m_GPUFlag == 1 && (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE))) { // Break after the draw m_GPUFlag = 0; } else if(m_GPUFlag == 0) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } else if(m_GPUFlag == 2 && addr == m_GPUData) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } else if(m_GPUFlag == 3 && (cmd == GE_CMD_PRIM || cmd == GE_CMD_BEZIER || cmd == GE_CMD_SPLINE)) { GPUgstate *state = (GPUgstate*)data; u32 texAddr = (state->texaddr[0] & 0xFFFFF0) | ((state->texbufwidth[0]<<8) & 0x0F000000); if(texAddr == m_GPUData) { mainWindow->GetDialogDisasm()->UpdateDisplayList(); mainWindow->GetDialogDisplaylist()->Update(); m_hGPUStepEvent.wait(m_hGPUStepMutex); } } EmuThread_LockDraw(true); }
void QtHost::SendGPUWait() { EmuThread_LockDraw(false); mainWindow->GetDialogDisasm()->UpdateDisplayList(); m_hGPUStepEvent.wait(m_hGPUStepMutex); EmuThread_LockDraw(true); }
void manageMachines(){ create("manageMachines"); double B,timeUsingMachine; while (1) { vendingMachineRequested.wait(); B = uniform(10,60); timeUsingMachine = 150 + uniform((B/2),30); waitVendingMachineOpen.set(); vendingMachineIsOpen.wait(); numberOfMachinesBeingUsed++; hold(timeUsingMachine); doneWithMachine.set(); numberOfMachinesBeingUsed--; } }
void sim(int argc, char *argv[]) { set_model_name("M/M/1 Queue"); create("sim"); cnt = NARS; for(int i = 1; i <= NARS; i++) { hold(expntl(IAR_TM)); // interarrival interval customer(); // generate next customer } done.wait(); // wait for last customer to depart report(); // model report theory(); mdlstat(); // model statistics }
void arr_cust() { create("arr_cust"); line.reserve(); // join the line and wait to be head vendingMachineRequested.set(); // i am the front of the line waitVendingMachineOpen.queue(); // wait for an open machine vendingMachineRequested.clear(); // vending machine is open and im taking it clear for next in line vendingMachineIsOpen.set(); // tell vending machine that i am about to use it. line.release(); // i am not the head of the line anymore pass it to next in line. doneWithMachine.wait(); // I am done after time to use machine is free and im leaving and dying. // set up shuttle process }
// Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { #if _DEBUG host->UpdateDisassembly(); #endif while (true) { reswitch: switch(coreState) { case CORE_RUNNING: //1: enter a fast runloop Core_RunLoop(); break; // We should never get here on Android. case CORE_STEPPING: //1: wait for step command.. m_hStepEvent.wait(m_hStepMutex); if (coreState == CORE_POWERDOWN) return; if (coreState != CORE_STEPPING) goto reswitch; currentCPU = &mipsr4k; Core_SingleStep(); //4: update disasm dialog #ifdef _DEBUG host->UpdateDisassembly(); host->UpdateMemView(); #endif break; case CORE_POWERDOWN: case CORE_ERROR: //1: Exit loop!! return; } } }
void Core_WaitInactive() { while (Core_IsActive()) { m_hInactiveEvent.wait(m_hInactiveMutex); } }
// Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { #if defined(_DEBUG) host->UpdateDisassembly(); #endif #if !defined(USING_QT_UI) || defined(USING_GLES2) while (true) #endif { reswitch: if (globalUIState != UISTATE_INGAME) { CoreStateProcessed(); if (globalUIState == UISTATE_EXIT) { return; } Core_RunLoop(); #if defined(USING_QT_UI) && !defined(USING_GLES2) return; #else continue; #endif } switch (coreState) { case CORE_RUNNING: // enter a fast runloop Core_RunLoop(); break; // We should never get here on Android. case CORE_STEPPING: singleStepPending = false; CoreStateProcessed(); // Check if there's any pending savestate actions. SaveState::Process(); if (coreState == CORE_POWERDOWN) { return; } // wait for step command.. #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); host->SendCoreWait(true); #endif m_hStepEvent.wait(m_hStepMutex); #if defined(USING_QT_UI) || defined(_DEBUG) host->SendCoreWait(false); #endif #if defined(USING_QT_UI) && !defined(USING_GLES2) if (coreState != CORE_STEPPING) return; #endif // No step pending? Let's go back to the wait. if (!singleStepPending || coreState != CORE_STEPPING) { if (coreState == CORE_POWERDOWN) { return; } goto reswitch; } Core_SingleStep(); // update disasm dialog #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); #endif break; case CORE_POWERUP: case CORE_POWERDOWN: case CORE_ERROR: // Exit loop!! CoreStateProcessed(); return; case CORE_NEXTFRAME: return; } } }
void local_event_test(event& b, boost::atomic<std::size_t>& c) { ++c; // Wait for the event to occur. b.wait(); }
// Some platforms, like Android, do not call this function but handle things on their own. void Core_Run() { #if defined(_DEBUG) host->UpdateDisassembly(); #endif #if !defined(USING_QT_UI) || defined(USING_GLES2) while (true) #endif { reswitch: switch (coreState) { case CORE_RUNNING: //1: enter a fast runloop Core_RunLoop(); break; // We should never get here on Android. case CORE_STEPPING: if (coreStatePending) { coreStatePending = false; m_hInactiveEvent.notify_one(); } //1: wait for step command.. #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); host->SendCoreWait(true); #endif m_hStepEvent.wait(m_hStepMutex); #if defined(USING_QT_UI) || defined(_DEBUG) host->SendCoreWait(false); #endif if (coreState == CORE_POWERDOWN) return; if (coreState != CORE_STEPPING) #if defined(USING_QT_UI) && !defined(USING_GLES2) return; #else goto reswitch; #endif currentCPU = &mipsr4k; Core_SingleStep(); //4: update disasm dialog #if defined(USING_QT_UI) || defined(_DEBUG) host->UpdateDisassembly(); host->UpdateMemView(); #endif break; case CORE_POWERDOWN: case CORE_ERROR: //1: Exit loop!! if (coreStatePending) { coreStatePending = false; m_hInactiveEvent.notify_one(); } return; case CORE_NEXTFRAME: return; } } }
void Core_WaitInactive() { while (!Core_IsInactive()) m_hInactiveEvent.wait(m_hInactiveMutex); }