SCP: Adjust RUNLIMIT time values on slow host systems

As reported and discussed in #819
This commit is contained in:
Mark Pizzolato 2020-03-21 21:30:58 -07:00
parent 45d7a1155b
commit ee317e0cb4
5 changed files with 33 additions and 2 deletions

View file

@ -8,6 +8,9 @@ cd %~p0
:: Limit maximum diagnostic execution time
runlimit 2 minutes
set on
on error ignore
on runtime echof "\r\n*** Test Runtime Limit %SIM_RUNLIMIT% %SIM_RUNLIMIT_UNITS% Exceeded ***\n"; exit 1
:: Maximum memory, extended address element:
set cpu 32k

View file

@ -19,6 +19,10 @@
#break A3B4 SHOW HIST=40
cd %~p0
set runlimit 2 minutes
set on
on error ignore
on runtime echof "\r\n*** Test Runtime Limit %SIM_RUNLIMIT% %SIM_RUNLIMIT_UNITS% Exceeded ***\n"; exit 1
set env DIAG_QUIET_MODE=0
if ("%1" == "-v") set console notelnet
else set -qu console telnet=localhost:65432,telnet=buffered; set env -a DIAG_QUIET_MODE=1

19
scp.c
View file

@ -7005,6 +7005,8 @@ char gbuf[CBUFSIZE];
int32 num;
t_stat r;
double usec_factor = 1.0;
const char *units = "";
char runlimit[32];
GET_SWITCHES (cptr); /* get switches */
if (0 == flag) {
@ -7014,6 +7016,8 @@ if (0 == flag) {
sim_runlimit_switches = 0;
sim_runlimit_enabled = FALSE;
sim_cancel (&sim_runlimit_unit);
unsetenv ("SIM_RUNLIMIT");
unsetenv ("SIM_RUNLIMIT_UNITS");
return SCPE_OK;
}
@ -7023,8 +7027,10 @@ if ((r != SCPE_OK) || (num == 0)) /* error? */
return sim_messagef (SCPE_ARG, "Invalid argument: %s\n", gbuf);
cptr = get_glyph (cptr, gbuf, 0); /* get next glyph */
if ((gbuf[0] == '\0') ||
(MATCH_CMD (gbuf, sim_vm_interval_units) == 0))
(MATCH_CMD (gbuf, sim_vm_interval_units) == 0)) {
sim_switches &= ~SWMASK ('T');
units = sim_vm_interval_units;
}
else {
int i;
struct {
@ -7042,6 +7048,7 @@ else {
if (MATCH_CMD (gbuf, time_units[i].name) == 0) {
sim_switches |= SWMASK ('T');
usec_factor = time_units[i].usec_factor;
units = time_units[i].name;
break;
}
}
@ -7054,11 +7061,19 @@ sim_runlimit_enabled = TRUE;
sim_cancel (&sim_runlimit_unit);
sim_runlimit_switches = sim_switches;
if (sim_runlimit_switches & SWMASK ('T')) {
sim_runlimit_d_initial = sim_runlimit_d = num * usec_factor;
sim_runlimit_d_initial = sim_runlimit_d = num * usec_factor * sim_host_speed_factor ();
if (sim_host_speed_factor () > 1.0)
sim_messagef (SCPE_OK, "Slow host - adjusting RUNLIMIT from %d %s to %.1f %s\n", num, units, num * sim_host_speed_factor (), units);
snprintf (runlimit, sizeof (runlimit), "%.f", num * sim_host_speed_factor ());
setenv ("SIM_RUNLIMIT", runlimit, 1);
setenv ("SIM_RUNLIMIT_UNITS", units, 1);
return sim_activate_after_d (&sim_runlimit_unit, sim_runlimit_d);
}
else {
sim_runlimit_initial = sim_runlimit = num;
snprintf (runlimit, sizeof (runlimit), "%d", num);
setenv ("SIM_RUNLIMIT", runlimit, 1);
setenv ("SIM_RUNLIMIT_UNITS", units, 1);
return sim_activate (&sim_runlimit_unit, sim_runlimit);
}
}

View file

@ -3467,3 +3467,11 @@ for (tmr=0; tmr<=SIM_NTIMERS; tmr++) {
sim_inst_per_sec_last = sim_precalibrate_ips;
sim_idle_stable = 0;
}
double
sim_host_speed_factor (void)
{
if (sim_precalibrate_ips > SIM_INITIAL_IPS)
return 1.0;
return (double)SIM_INITIAL_IPS / (double)sim_precalibrate_ips;
}

View file

@ -158,6 +158,7 @@ t_stat sim_os_set_thread_priority (int below_normal_above);
uint32 sim_get_rom_delay_factor (void);
void sim_set_rom_delay_factor (uint32 delay);
int32 sim_rom_read_with_delay (int32 val);
double sim_host_speed_factor (void);
extern t_bool sim_idle_enab; /* idle enabled flag */
extern volatile t_bool sim_idle_wait; /* idle waiting flag */