1
0
mirror of https://github.com/simh/simh.git synced 2026-02-27 01:00:07 +00:00

IBM1130: Avoid Windows GUI startup for RegisterSanityCheck testing

Also synchronize Window Event pump and command input thread startup
before counting on their use.

Previously the Windows GUI startup happened too early (in the power on
device reset of all DEVICES) and it didn't consistently stabilize before
proceeding.  A quick exit after the RegisterSanityCheck activity would
sometimes hang and builds would never complete.
This commit is contained in:
Mark Pizzolato
2022-10-29 07:29:16 -10:00
parent aad6cb5fc0
commit 18d54161bd

View File

@@ -132,7 +132,6 @@ t_stat console_reset (DEVICE *dptr)
hConsoleWindow = GetConsoleWindow();
}
update_gui(FALSE);
return SCPE_OK;
}
@@ -212,6 +211,8 @@ static HDC hCDC = NULL;
static char szConsoleClassName[] = "1130CONSOLE";
static DWORD PumpID = 0;
static HANDLE hPump = INVALID_HANDLE_VALUE;
static HANDLE hPumpReadyEvent = NULL;
static int bmwid, bmht;
static HANDLE hbm1442_full, hbm1442_empty, hbm1442_eof, hbm1442_middle;
static HANDLE hbm1132_full, hbm1132_empty;
@@ -301,9 +302,14 @@ static void init_console_window (void)
if (hConsoleWnd != NULL)
return;
if ((hPumpReadyEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL)
scp_panic("Can't create pump ready event");
if (PumpID == 0)
hPump = CreateThread(NULL, 0, Pump, 0, 0, &PumpID);
WaitForSingleObject (hPumpReadyEvent, INFINITE);
if (! did_atexit) {
atexit(destroy_console_window);
did_atexit = TRUE;
@@ -327,6 +333,12 @@ static void destroy_console_window (void)
PumpID = 0;
hConsoleWnd = NULL;
}
if (hPumpReadyEvent != NULL) {
CloseHandle (hPumpReadyEvent);
hPumpReadyEvent = NULL;
}
if (hCDC != NULL) {
DeleteDC(hCDC);
hCDC = NULL;
@@ -907,6 +919,8 @@ static DWORD WINAPI Pump (LPVOID arg)
}
}
SetEvent (hPumpReadyEvent);
if (running) /* if simulator is already running, start update timer */
gui_run(TRUE);
@@ -1670,6 +1684,7 @@ static DWORD WINAPI CmdThread (LPVOID arg)
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
DWORD dwBytesRead;
SetEvent(hCmdReadyEvent); /* notify main thread a line is ready */
for (;;) {
if (WAIT_TIMEOUT == WaitForSingleObject(hCmdReadEvent, 2000)) /* wait for request */
continue; /* put breakpoint here to debug */
@@ -1725,7 +1740,7 @@ char *read_cmdline (char *ptr, int size, FILE *stream)
if ((hCmdThread = CreateThread(NULL, 0, CmdThread, NULL, 0, &iCmdThreadID)) == NULL)
scp_panic("Unable to create command line reading thread");
atexit(read_atexit);
Sleep(500); /* Let GUI threads startup and start to process messages */
WaitForSingleObject(hCmdReadyEvent, INFINITE); /* wait for read thread to start */
}
update_gui(TRUE);