Commit graph

170 commits

Author SHA1 Message Date
Mark Pizzolato
ee317e0cb4 SCP: Adjust RUNLIMIT time values on slow host systems
As reported and discussed in #819
2020-03-21 21:30:58 -07:00
Mark Pizzolato
550837b15b TIMER: Prefer a stable calibrated clock which ticks slower than the host 2020-03-08 21:11:30 -07:00
Mark Pizzolato
0170b7c6ab SCP: Convert more SHOW and debug output to use sim_vm_interval_units 2020-03-08 11:43:30 -07:00
Mark Pizzolato
56f186135c TIMER: Fix startup/restart logic that accounts for time at the sim> promt 2020-03-07 21:24:03 -08:00
Mark Pizzolato
938aa58f3a SCP: Provide ways for VM to specify sim_interval adjustment and step units
This affects the output of some SCP commands (including help).  The
results are cosmetic, but allows the simulator to provide correct descriptive
information.
2020-03-07 10:13:18 -08:00
Mark Pizzolato
42bb47d961 TIMER: Be sure to empty the event queue at timer initialization
If a reset_all_p() happens before the timing subsystem is initialized,
events can be queued with unreasonable timing measurements.
2020-03-07 07:05:46 -08:00
Mark Pizzolato
26fa91a335 TIMER: Avoid clocks with changing tick rates as the primary calibrated timer
Some simulators have clocks that have dynamically programmable tick
rates. Such a clock is only a reliable candidate to be the calibrated
clock if it uses a single tick rate rather than changing the tick rate
on the fly.  Generally most systems like this, under normal conditions
don't change their tick rates unless they're running something that is
examining the behavior of the clock system (like a diagnostic).  Under
these conditions this clock is removed from the potential selection as
"the" calibrated clock that all others are relative to and if necessary,
an internal calibrated clock is selected.
2020-02-23 00:31:45 -08:00
Mark Pizzolato
73a41c4bc7 SCP: Auto detect WRU being entered for simulators without a console device 2019-12-11 12:25:18 -08:00
Mark Pizzolato
2840e3b67f SCP: Fix Coverity identified issues/noise 2019-07-15 00:04:40 -07:00
Mark Pizzolato
b3fa1f9fe8 TIMER: Stabilize timer behaviors
- Fix incomplete migration to RTC structures indicated by Coverity
  warnings.  Some Coverity were minor warnings and not real issues.
- Add calibration recovery parameters for idle and catchup ticks
- Aggressively perform catchup ticks when in simulated idle paths
  even when idling is disabled.
- All non internal clocks can have catch-up ticks triggered if they
  register a tick unit.
- Catch-up ticks will be delivered to non tick acking simulators when
  idling if regstered tick unit has been specified.
- Hosts with slow ticks can idle and keep sloppy OK time when
  simulators have faster ticks
- Default to active calibration (ALWAYS) while idling (no skipping)
2019-06-18 08:01:45 -07:00
Mark Pizzolato
8c4f8b0bff TIMER: Accelerate catchup ticks while idling
- Avoid default idle stability wait when pre-calibrate has succeeded
- Display time at sim> prompt in SHOW CLOCK output
2019-06-10 14:55:05 -07:00
Mark Pizzolato
9ab8d0e91e TIMER: Add debug of all calibration decision variables default no idle skip 2019-06-08 16:38:15 -07:00
Mark Pizzolato
7bcf407fcc TIMER: Reorganize timer control variables to use a structure for each timer
The original approach had separate parallel arrays for each relevant
state variable for each calibrated timer.  That worked when there were
only a few state variables, the state info for a timer belongs in a
structure.
2019-06-08 13:55:49 -07:00
Mark Pizzolato
da3f851d70 TIMER: Add minimal tick based calibration APIs. 2019-06-08 13:55:06 -07:00
Mark Pizzolato
9514ea5a58 TIMER: Stabilize run away clock calibration conditions
- Adjust calibration parameters to properly record catchup variables for
  odd condition cases.
- Disable idle percentage calibration skipping until the correct set of
  calibration variables are available.
- When a pre-calibrate operation has been performed, make the results
  visible in the output of SHOW CLOCK

As discussed in #705 and #699
2019-06-03 20:45:40 -07:00
Mark Pizzolato
217463c6e2 TIMER: Also account for sim> prompt time in catchup time calculations
As discussed in #705
2019-06-01 02:33:02 -07:00
Mark Pizzolato
564ce2b3f4 TIMER: Don't consider idle calibration skipping with internal timer
As discussed in #699
2019-05-30 03:23:38 -07:00
Mark Pizzolato
0195bbda4b TIMER: Fix missing catchup ticks for VAX simulators when idling
- MicroVAX I, II and 3900 don't have a DONE bit in the clock status
  register, so sim_rtcn_tick_ack() wasn't being called to acknowledge
  clock ticks.
- Timer catchup tick criteria didn't work unless the host had a slow
  clock tick.

As discussed in #705
2019-05-30 01:51:52 -07:00
Mark Pizzolato
f75f28aa21 TIMER: Add mechanism to pre-calibrate the instruction execution rate 2019-05-28 23:56:58 -07:00
Mark Pizzolato
48db10994d TIMER: Calibrated clock fixes
- Properly handle clock transitions when control flows back and forth
  between instruction execution and simh commands.
- Changed Internal Timer from 10 Hz to the MAX(100Hz, HostOSClockHz)
- Changed default idle calibration percent to 50%
- Make sure that error cases (backwards and gap too big) properly advance
  the real time while avoiding calibration.
- Fix selection of the calibrated clock.
- Fix logic that sets the idle percentage that controls calibration.
2019-05-28 22:47:06 -07:00
Mark Pizzolato
5fdc1e6d0f SCP: Add more clock adjustments while idling 2018-10-08 20:55:01 -07:00
Mark Pizzolato
948d8cc6e8 TIMER: Remove excessive adjustment of sim_interval while idling 2018-10-05 20:44:22 -07:00
Mark Pizzolato
b38cc8a367 SCP: Allow "STEP -T nnn" to work
Delay scheduling of long duration calibration events until a calibrated timer
is established.
2018-10-05 20:43:43 -07:00
Mark Pizzolato
3a9a15f3a9 TIMER: Allow short duration sim_instr() exits to avoid recalibrating timers
- sim_instr() returns to scp (during script execution) that start simulation
  again in less than 1 tick of the calibrated clock now leverage the previous
  calibration state when instruction execution resumes.
- Only generate catchup ticks for clocks that are still running.
- Revert windows sim_os_msec() implementation back to use the multi-media
  timer which is required on Windows XP and shouldn't be affected by dynamic
  OS time adjustments that do affect System Time.
2018-09-28 18:04:34 -07:00
Mark Pizzolato
f48c282dff SCP: Silence potential compiler warnings on Windows using GCC 2018-09-27 22:01:40 -07:00
Mark Pizzolato
6070692581 SCP: Add unit to AIO_VALIDATE context message 2018-08-08 11:51:54 -07:00
Mark Pizzolato
0d9f195f1c TIMER: Timing updates
- Reliably align clock measurements on tick boundary before measuring.
- Use consistent timebase for time measurements in sim_idle_ms_sleep()

Windows:
- Properly restore system clock tick size on exit.
- Use highest resolution time for ms time measurements
2018-08-06 19:54:29 -07:00
Mark Pizzolato
15885fdf6a TIMER: optimize time format conversion routine 2018-08-06 07:38:08 -07:00
Mark Pizzolato
b25a19769e TIMER: Tolerate negative usec activation delays and pass thru as instructions 2018-07-17 15:34:08 -07:00
Mark Pizzolato
e537e4d8fe TIMER: Fix additional timespec overflow cases in diff and compares 2018-07-15 10:18:30 -07:00
Mark Pizzolato
97bee79faa TIMER: Fix overflow error in sim_idle_ms_sleep() timespec tv_nsec field
Backed out commit 484889ea5a since the overflow of the timespec tv_nsec
field was the real cause of the problem.  No need for an extra mutex.

As reported in #595
2018-07-15 10:11:14 -07:00
Mark Pizzolato
484889ea5a TIMER: Changed sim_idle_ms_sleep() to use a mutex which is unique to idling
It seems that the prior use of sim_asynch_lock RECURSIVE mutex could
cause a pthread_cond_timedwait() failure with EINVAL returned.
As discussed in #595
2018-07-11 11:59:05 -07:00
Mark Pizzolato
d593cdb98b SCP: Add prompt prior to fatal exit allowing error messages reading
As discussed in #594
2018-07-08 14:55:55 -07:00
Mark Pizzolato
9b95115a2a TIMER: Add abort logic if sim_idle_ms_sleep() sleeps for 0 with an error
As discussed in #594
2018-07-08 13:53:28 -07:00
Mark Pizzolato
076af54ad3 TIMER: Report available details when unexpected timer subsystem errors occur
A graceful exit with the unexpected results reported now is provided.
As discussed in #594
2018-07-08 11:53:20 -07:00
Mark Pizzolato
d20ef039e7 TIMER: Properly identify short vs long (multi-tick) delays for co-scheduling 2018-06-20 11:57:15 -07:00
Mark Pizzolato
681ed2d6f9 TIMER: Minimize noise in idle debug output for short idle delays 2018-06-15 11:27:23 -07:00
Mark Pizzolato
6b7798781d TIMER: Allow recording of elapsed time when asynch events arrive while idling
As discussed in #578
2018-06-14 12:40:22 -07:00
Mark Pizzolato
93f92b7fb3 TIMER: Fix edge condition when scheduling timer delays with clock tick pending 2018-06-11 03:16:12 -07:00
Mark Pizzolato
ed2abaa2d8 SCP: Enhance debug output while tracking event and timer activity 2018-06-11 03:13:29 -07:00
Mark Pizzolato
b51d250598 SCP: Ignore trailing whitespace for all commands 2018-05-18 08:32:03 -07:00
Mark Pizzolato
ded2b20fe0 TIMER: Tolerate trailing spaces on SET THROTTLE arguments 2018-05-18 08:15:03 -07:00
Mark Pizzolato
a47c04bcac TIMER: Fix throttle startup delay check 2018-04-06 02:20:29 -07:00
Mark Pizzolato
2bcb60e76f TIMER: Add external initialization option for clock calibration
Clock calibration normally takes several seconds to zero in on somewhat
accurate values for reasonable synchronization of simulated time to wall
clock time.  Often this doesn't matter one way or another.  However,
one thing which requires somewhat accurate clock calibration is the
pacing of output to serial ports on the host system.  Pacing happens
at the configured bits per second rates as long as the simulators
instruction execution rate has been reasonably calibrated with respect
to wall clock time.  A given host system will most likely simulate
instructions at the same rate from one run to the next, so running a
simulator for a little while and then examining the execution rate with
the SHOW CLOCK command can provide knowledge about the calibrated
execution rate which can be used to start a future simulator's execution
with a very good estimate of what the ultimate calibrated rate will be.
If the SHOW CLOCK shows simulator execution at 120,000,000 instructions
per second, and the simulated system has a simulated clock that runs at
60 hz, then the pre-calibrated values can be set with these commands:

    sim> DEPOSIT INT-CLOCK TICK_SIZE_0 2000000
    sim> DEPOSIT INT-CLOCK TICK_RATE_0 60
    sim> DEPOSIT INT-CLOCK INTERNAL_TICK_SIZE 12000000

The INTERNAL_TIMER runs in the background whenever the simulator
doesn't have a calibrated timer running.  It runs at 10 Hz.
2018-04-06 01:46:44 -07:00
Mark Pizzolato
317e2a8e54 TIMER: make sim_activate_after use coscheduling whenever possible.
Previously, only long delays that would transition the next clock
calibration would be coscheduled unless an explicit timer was
specified to coschedule with.

This may help with the problem discussed in #508
2018-04-03 02:06:14 -07:00
Mark Pizzolato
097ebbb8eb TIMER: Synchronize clock calibration with throttled rate when throttling starts
As discussed in #508
2018-01-28 08:23:45 -08:00
Mark Pizzolato
7fbe5e8530 TIMER: Avoid throttling recalibration when resuming execution
As discussed in #508
2018-01-23 08:53:04 -08:00
Mark Pizzolato
fd80be4e91 TIMER: Properly serialize (and reference) asynch timer thread state
Without this change, timer events don't get queued correctly when the
simulator isn't running (i.e. when at the command prompt or as a consequence
of a RESET command (or during boot preparation)).

This only affects when timers are asynchronous which is not the current
default.
2018-01-23 07:30:20 -08:00
Mark Pizzolato
f3d1076887 TIMER: Fix throttling calibration and recalibration
- Throttling delays are self adjusting for specific speed throttling
   (K cycles and M cycles and % cycles).
- Throttling starts after THROT_DELAY seconds of execution.
- THROT_DELAY is a register accessible via EXAMINE and DEPOSIT
   once throttling has been enabled.
- Throttle sleep times are recalibrated every 10 seconds based on
   execution performance for the prior 10 seconds if the current
   execution rate differs from the desired rate by more than
   THROT_DRIFT_PCT.  THROT_DRIFT_PCT defaults to 5 and is a
   register accessible via EXAMINE and DEPOSIT once throttling has
   been enabled.
- Addressing details reported in #508
2018-01-16 21:44:25 -08:00
Mark Pizzolato
a4a6a1d409 SCP: Fix regression which disabled limit check when parsing unsigned integers
This affected unit and tmxr line checks when there was only one unit or line.
2017-12-05 12:23:31 -08:00