From df96d1dbe1385325e1214ee6ed9c5bf7cc9ba74f Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 13 Oct 2023 09:37:20 -1000 Subject: [PATCH] SCP: Reject throttling setting when throttling was previously enabled --- README.md | 1 + sim_timer.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 09bee77f..9337e8ed 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Simulator binaries for x86 Linus, x86 macOS, and Windows for all recent changes - VHD Support for Differencing Disks has been corrected. - Attach time disk container copy support between dissimilar storage formats (VHD<->SIMH). Previously container copy operations were only supported between identical format containers (SIMH<->SIMH, and VHD<->VHD). - DISKINFO command provides more useful metadata information and file system verification with full support for VHD Differencing Disks. +- Simulator THROTTLING can only be enabled once per simulator run. This avoids potential errant behaviors when arbitrarily switching throttling settings. #### Changes to the PDP-11 and VAX simulators also not in the Open SIMH repo diff --git a/sim_timer.c b/sim_timer.c index 8f8f09a5..7e662418 100644 --- a/sim_timer.c +++ b/sim_timer.c @@ -186,6 +186,7 @@ static uint32 sim_throt_delay = 3; static int32 sim_int_clk_tps; static t_bool sim_timer_calib_enabled = TRUE; static struct timespec sim_timer_uncalib_base_time = {0, 0}; +static t_bool sim_throttle_has_been_enabled = FALSE; typedef struct RTC { UNIT *clock_unit; /* registered ticking clock unit */ @@ -1863,6 +1864,7 @@ t_stat sim_set_throt (int32 arg, CONST char *cptr) { CONST char *tptr; char c; +uint32 saved_throt_type = sim_throt_type; t_value val, val2 = 0; if (arg == 0) { @@ -1899,6 +1901,10 @@ else { else if ((c == '/') && (val2 != 0)) sim_throt_type = SIM_THROT_SPC; else return sim_messagef (SCPE_ARG, "Invalid throttle specification: %s\n", cptr); + if (sim_throttle_has_been_enabled) { + sim_throt_type = saved_throt_type; + return sim_messagef (SCPE_ARG, "Throttling was previously enabled. Restart to change throttling\n"); + } if (sim_idle_enab) { sim_printf ("Idling disabled\n"); sim_clr_idle (NULL, 0, NULL, NULL); @@ -1925,6 +1931,7 @@ if (sim_throt_type == SIM_THROT_SPC) /* Set initial value while correct one i sim_throt_cps = (int32)((1000.0 * sim_throt_val) / (double)sim_throt_sleep_time); else sim_throt_cps = sim_precalibrate_ips; +sim_throttle_has_been_enabled = TRUE; return SCPE_OK; }