diff --git a/scp.c b/scp.c index 15d9f44b..3970ed89 100644 --- a/scp.c +++ b/scp.c @@ -12438,6 +12438,15 @@ UPDATE_SIM_TIME; /* update sim time */ sim_debug (SIM_DBG_ACTIVATE, &sim_scp_dev, "Activating %s delay=%d\n", sim_uname (uptr), event_time); +/* event_time being -1 is a special case which specifically pushes the */ +/* specified unit at the head of the event queue */ +if (event_time == -1) { + uptr->time = 0; + uptr->next = sim_clock_queue; + sim_clock_queue = uptr; + sim_interval = 0; + return SCPE_OK; + } prvptr = NULL; accum = 0; for (cptr = sim_clock_queue; cptr != QUEUE_LIST_END; cptr = cptr->next) { diff --git a/sim_console.c b/sim_console.c index 04dc329e..c3ace0ba 100644 --- a/sim_console.c +++ b/sim_console.c @@ -927,8 +927,8 @@ if (sim_vm_post != NULL) /* optionally let the simulator (*sim_vm_post) (TRUE); /* something might have changed */ if (!sim_processing_event) { sim_ttrun (); /* set console mode */ - sim_cancel (rem_con_data_unit); /* force immediate activation of sim_rem_con_data_svc */ - sim_activate (rem_con_data_unit, -1); + sim_cancel (rem_con_data_unit); /* force immediate activation of sim_rem_con_data_svc with the */ + sim_activate (rem_con_data_unit, -1); /* special case delay (-1) which forces it to the head of the queue */ } sim_switches = saved_switches; /* restore original switches */ } diff --git a/sim_frontpanel.c b/sim_frontpanel.c index 4599fcb0..95a5b9e6 100644 --- a/sim_frontpanel.c +++ b/sim_frontpanel.c @@ -80,6 +80,26 @@ tp->tv_sec = (long)(now/10000000); tp->tv_nsec = (now%10000000)*100; return 0; } + +static const char *GetErrorText (DWORD dwError) +{ +static __declspec (thread) char szMsgBuffer[2048]; +DWORD dwStatus; + +dwStatus = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM| + FORMAT_MESSAGE_IGNORE_INSERTS, // __in DWORD dwFlags, + NULL, // __in_opt LPCVOID lpSource, + dwError, // __in DWORD dwMessageId, + 0, // __in DWORD dwLanguageId, + szMsgBuffer, // __out LPTSTR lpBuffer, + 2048, // __in DWORD nSize, + NULL); // __in_opt va_list *Arguments +if (0 == dwStatus) + _snprintf(szMsgBuffer, sizeof(szMsgBuffer), "Error Code: %d", dwError); +while (isspace(szMsgBuffer[strlen(szMsgBuffer)-1])) + szMsgBuffer[strlen(szMsgBuffer)-1] = '\0'; +return szMsgBuffer; +} #else /* NOT _WIN32 */ #include #define msleep(n) usleep(1000*n) @@ -860,7 +880,7 @@ if (!simulator_panel) { p->dwProcessId = ProcessInfo.dwProcessId; } else { /* Creation Problem */ - sim_panel_set_error (NULL, "CreateProcess Error: %d", GetLastError()); + sim_panel_set_error (NULL, "CreateProcess Error: %d", GetErrorText(GetLastError())); goto Error_Return; } #else @@ -1068,13 +1088,15 @@ if (panel) { /* Now close the socket which should stop a pending read that hasn't completed */ sim_close_sock (sock); pthread_join (panel->io_thread, NULL); + + if ((panel->Debug) && (panel->parent == NULL)) + pthread_join (panel->debugflush_thread, NULL); + /* panel mutexes and condition variables are only initialize after a successful socket open */ + pthread_mutex_destroy (&panel->io_lock); + pthread_mutex_destroy (&panel->io_send_lock); + pthread_mutex_destroy (&panel->io_command_lock); + pthread_cond_destroy (&panel->io_done); } - if ((panel->Debug) && (panel->parent == NULL)) - pthread_join (panel->debugflush_thread, NULL); - pthread_mutex_destroy (&panel->io_lock); - pthread_mutex_destroy (&panel->io_send_lock); - pthread_mutex_destroy (&panel->io_command_lock); - pthread_cond_destroy (&panel->io_done); #if defined(_WIN32) if (panel->hProcess) { GenerateConsoleCtrlEvent (CTRL_BREAK_EVENT, panel->dwProcessId); @@ -1082,6 +1104,7 @@ if (panel) { TerminateProcess (panel->hProcess, 0); WaitForSingleObject (panel->hProcess, INFINITE); CloseHandle (panel->hProcess); + panel->hProcess = NULL; } #else if (panel->pidProcess) { @@ -1094,6 +1117,7 @@ if (panel) { kill (panel->pidProcess, SIGKILL); } waitpid (panel->pidProcess, &status, 0); + panel->pidProcess = 0; } #endif free (panel->path); diff --git a/sim_frontpanel.h b/sim_frontpanel.h index 0e03a882..844c8343 100644 --- a/sim_frontpanel.h +++ b/sim_frontpanel.h @@ -56,7 +56,7 @@ extern "C" { #if !defined(__VAX) /* Unsupported platform */ -#define SIM_FRONTPANEL_VERSION 12 +#define SIM_FRONTPANEL_VERSION 13 /**