Commit graph

177 commits

Author SHA1 Message Date
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
Mark Pizzolato
2435311072 SCP: Add DEV_NOSAVE flag for throttle and console internal devices 2017-10-08 10:10:03 -07:00
Mark Pizzolato
b2b18de0ec TIMER: Use standard calibration techniques while throttling
Part of a previous change introduced logice which used the throttling
execution rate calibrated value to determine clock calibration when
throttling is enabled.  This provides significantly worse results than the
normal self correcting calibration process.  This commit reverses that
part of the previous change.
2017-08-03 18:51:55 -07:00
Mark Pizzolato
a02e9c1111 TIMER: Assure that long duration co-scheduled events are properly dispatched
As discussed in #478
2017-08-01 06:49:05 -07:00
Mark Pizzolato
d6316cbd03 TIMER: Add SET CLOCK STOP=nnn to stop execution after nnn instructions
This allows potential debug information to be bounded when execution is
started using BOOT or NEXT.
2017-08-01 06:32:18 -07:00
Mark Pizzolato
17cc00f33e TIMER: Fix threshold for short vs long interval delay scheduling 2017-06-13 08:18:10 -07:00
Mark Pizzolato
d9e7afc92f SCP: Fix Coverity flagged issues 2017-06-13 04:32:18 -07:00
Mark Pizzolato
9accb79b92 TIMER: Properly calibrate clocks while throttling 2017-06-11 05:00:42 -07:00
Mark Pizzolato
54993732dd TIMER: Properly queue all clocks when returning from sim_instr()
as reported in #460
2017-05-29 23:12:37 -07:00
Mark Pizzolato
1e8af71081 TIMER: Clarify throttling behavior displayed in SHOW for I/T mode 2017-05-11 08:33:39 -07:00
Mark Pizzolato
85c27bb099 TIMER: Fix typo in a comment text 2017-05-09 20:05:11 -07:00
Mark Pizzolato
12f43e660f TIMER: Behave reasonably when a simulator doesn't associate a UNIT with a timer 2017-03-12 17:59:23 -07:00
Mark Pizzolato
733653092f TIMER: Properly initialize clock coschedule queues 2017-02-04 11:38:56 -08:00
Mark Pizzolato
9e9658f30c TIMER: Cleanup compiler warning 2017-01-20 12:53:39 -08:00
Mark Pizzolato
57d14e5b4a TIMER: Fix coschedule bookkeeping on pending event interval 2017-01-19 11:12:06 -08:00
Mark Pizzolato
e36873f466 TIMER: Fix coscheduling functionality to produce consistent results
Added debug CHECK option to the sim_timer_activate_after() to verify
that coscheduled events actually have sim_activate_time_usecs() results
which are consistent with each other.
Additionally, coschedule tick processing now properly counts down
pending coschedule queued activities.
2017-01-18 23:53:46 -08:00
Mark Pizzolato
34ffe98605 TIMER: Fixed generic coscheduling and extended details in debug information 2017-01-17 16:29:55 -08:00
Mark Pizzolato
bdb0597411 TIMER: Fixed Internal Timer Support (canceling and activation time)
Also:
- Fix sim_timer_activate_time_usecs value size limits for ASYNCH timers
2017-01-09 17:38:09 -08:00
Mark Pizzolato
f698a215b4 TIMER: Fix sim_timer_is_active for internal timer unit 2017-01-05 10:44:49 -08:00
Mark Pizzolato
e450edd6ce SCP: Display most recent instruction execution rate in SHOW QUEUE output 2017-01-05 06:24:25 -08:00
Mark Pizzolato
b800587f34 TIMER: Add calibrated ROM memory access support 2017-01-05 05:50:46 -08:00
Mark Pizzolato
9c89b0e08b TIMER: Fix sim_timer_activate_time_usecs for clock units 2017-01-05 04:42:40 -08:00
Mark Pizzolato
711f6167fb TIMER: Make sure remnant usecs are always explicitly removed 2016-12-30 15:38:40 -08:00
Mark Pizzolato
c9276407e6 TIMER: Timing corrections and enhancements
- Add support to query remaining usecs on pending events.
- Generalized the sim_interval adjustment in sim_idle to allow more than
   a single decrement.
- More overhead reduction when idling.
- Carry usec values as double through out to fully support long wall clock
   delays.
2016-12-30 10:26:59 -08:00
Mark Pizzolato
7ec2ea836e TIMER: Properly transition internal timer after rebooting
- General cleanup of debug formatting and show device/features output
2016-12-28 13:25:11 -08:00
Mark Pizzolato
aa82b57d10 TIMER: Fix various inconsistent timing behaviors
- Support for arbitrary long wait intervals in sim_activate_after with
   precisely correct delays aligned with the calibrated clock once
   per second.
- Proper handling of calls to sim_cancel for calibrated timer units
- Properly allow stopping of calibrated clock by calling sim_rtcn_calb
   with a ticksper == 0
- Only schedule asynchronous timer activities for delays longer than
   the minimal OS sleep time
- Only wake asynchronous timer thread to queue new timer events
   that are shorter than the currently shortest scheduled event
2016-12-26 12:42:25 -08:00
Mark Pizzolato
7c2d20f26f SCP: Make sim_cancel more efficient by stopping search as soon as canceled 2016-12-24 09:49:32 -08:00
Mark Pizzolato
36276a79e1 SCP: Add device descriptions to internal devices visible in SHOW FEATURE -I 2016-12-18 13:33:11 -08:00
Mark Pizzolato
48e0b47d51 SCP: Add a way to see the enabled SCP internal devices SHOW DEV -I 2016-12-17 10:35:56 -08:00
Mark Pizzolato
740a506bcb TIMER: Add additional statistic info for SHOW CLOCKS
Also:
- Avoid potential divide by zero when stopping a running calibrated clock.
- Quickly reflect newly calibrated clock info in additional timers that may be running
2016-12-16 12:34:17 -08:00
Mark Pizzolato
ae52f4c331 TIMER: Add correct sim_activate_time functionality for all timer cases.
Also:
- allow a timer to dynamically stop itself (by calling sim_rtcn_calb
   with tps=0), and then to start the internal timer to provide a calibration
   baseline if necessary.
- Fix coschedule interval computation when the queue is empty.
- Properly select the correct timer for coscheduling without a specific tmr
- Properly adjust the coschedule queue's next time value when entries are
   canceled.
- Cleaned up throttling to behave well with all potential throttling rates and
   to make visible what is happening when boundaries are reached.
2016-12-15 09:57:34 -08:00
Mark Pizzolato
7db2dc10de TIMER: Fix coschedule dispatch logic and internal timer cleanup
Additionally, calls to sim_activate_after with delay values that exceed
twice the tick size of the calibrated clock are now coscheduled with
the calibrated clock.
2016-12-12 01:50:09 -08:00
Mark Pizzolato
5d8553e24c TIMER: Enabled catchup clock ticks
Historically, hosts which have a tick size slower than the tick a simulator
wants to implement can't idle effectively and keep good time.

This change allows simulators which call sim_rtcn_tick_ack() to provide
useful idling behavior while still keeping the passage of wall clock time
to time in the simulator accurate.
2016-12-10 11:59:49 -08:00
Mark Pizzolato
19250950c5 TIMER: Change internal THROTTLE device name to avoid SET THROTTLE collision 2016-12-07 16:17:40 -08:00
Mark Pizzolato
0a7996d9e3 TIMER: Fix statistics for Internal Timer and operation with multiple timers 2016-12-06 15:49:13 -08:00
Mark Pizzolato
eb333a845e TIMER: Fixed calibration idle skip percent logic
Also:
 - Added more statistics
 - Made sleep measurements more precise
 - Correct idle sleep decision logic without regard to host tick size
 - Fix calibration setup/teardown when host tick size is large (>10ms)
 - Generalized large host tick test capability (MS_MIN_GRANULARITY)
 - Fixed Windows sim_os_msec() to always use timeGetTime()
 - Fixed coschedule routines (that don't mentoin a tmr) to default to
    timer 0 and fallback to the internal timer otherwise.
 - Removed dependency on sizeof(tv_sec) in timespec structure for MinGW
2016-12-05 15:32:29 -08:00
Mark Pizzolato
60fb70128c TIMER: Add additional calibration skip while idling counter statistic 2016-11-28 17:40:24 -08:00
Mark Pizzolato
b83dae2db2 TIMER: Make sure internal timer doesn't restart after a CONTINUE unless needed 2016-11-27 12:37:35 -08:00
Mark Pizzolato
1ec46fbe11 TIMER: Make sure timers are properly saved and restored after ^E CONTINUE 2016-11-24 01:21:36 -08:00
Mark Pizzolato
be47d8539f TIMER: Fix Idling when transitioning betwen multiple calibrated clocks 2016-11-22 22:06:25 -08:00
Mark Pizzolato
89e372ba92 TIMER: Restore functionality for clocks devices that don't use sim_activate_after
Clock devices which call sim_register_clock_unit or sim_register_clock_unit_tmr
are best behaved if they use sim_activate_after to schedule their tick events.
2016-11-22 01:24:26 -08:00
Mark Pizzolato
f046171269 TIMER: Fix problem activation time for clock units 2016-11-20 13:06:41 -08:00
Mark Pizzolato
fc3ac62218 TIMER: Fix coscheduling to avoid a 0 delay interval
When the timer subsystem hasn't gotten fully initialized, devices may
attempt to coschedule schedule events before the clock has gotten
far enough along to be fully initialized.  When this happens we now
make sure to avoid the potential for a zero delay which will may cause
an infinite scheduling loop.
2016-11-17 16:25:19 -08:00
Mark Pizzolato
39d2944ede TIMER: Add support for catchup clock ticks and cleaned up asynchronous clocks
Asynchronous clocks are now built for all simulators which are built with
SIM_ASYNCH_IO defined.  The default behavior has asynchronous clocks
disabled since this is still experimental, but it can be enabled with
SET TIMER ASYNC.

Catchup clock ticks are now available, but since they're experimental,
they aren't enabled by default.  Catchup ticks are only available if the
simulators clock device calls sim_rtcn_tick_ack to acknowledge processing
of clock ticks.  The VAX simulators have been modified to leverage this.
Catchup clock ticks can be enabled with SET TIMER CATCHUP

Additionally, an idle threshold is provided which can be used to
influence when clock calibration may be suppressed.  The default is not
to suppress calibration activities.

The various timer behaviors are visible with the SHOW TIMER command.

The state of the operating timer facilities is visible with: SHOW CLOCK

Timer events which are queued are visible with the SHOW QUEUE command.
2016-11-16 23:50:53 -08:00