Commit graph

54 commits

Author SHA1 Message Date
Mark Pizzolato
8233fdc3c1 TIMER: Run simulator pre-calibration for a minimum of 100ms
Faster host systems today can get very fast instruction execution rates
for a short duration calibration test.  These may be skewed by round
off error, so we now run the calibration for a minimum of 100ms.
2020-11-18 14:47:42 -08:00
Mark Pizzolato
a41f081e81 TIMER: Add a generic time API to return the SCP time base 2020-10-29 12:57:47 -07:00
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
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
da3f851d70 TIMER: Add minimal tick based calibration APIs. 2019-06-08 13:55:06 -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
2ddc0e61ad TIMER: Define HAVE_STRUCT_TIMESPEC consistently for compiler compatibility
As mentioned in #606
2018-08-06 13:15:09 -07: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
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
b800587f34 TIMER: Add calibrated ROM memory access support 2017-01-05 05:50:46 -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
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
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
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
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
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
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
Mark Pizzolato
2b61a9a92d SCP: Fix timer calibration to produce consistent results with multiple clocks
- Timers that schedule their ticks with sim_activate_after() now operate
   consistently without having to be the single timer used by a simulator.
- Simulators which dynamically enable the operation of a clock when one
   wasn't previously wasn't enabled will disable the internal calibrated timer.
2016-09-26 15:39:42 -07:00
Mark Pizzolato
a008b0a972 SCP: Fix throttling to provide reasonable operation of calibrated clocks
- Generate reasonable messages when presented with erroneous throttle input.
- Add throttling recalibration logic if only if target rate drift exceeds 5%
2016-09-14 14:12:24 -07:00
Mark Pizzolato
a24aba69ae VIDEO: Added priority boost to thread performing SDL processing and updates
Reworked all priority adjustment code to leverage a new
sim_os_set_thread_priority API which is coded to use pthreads or OS
priority adjustment APIs as necessary.
2016-06-11 09:52:33 -07:00
Mark Pizzolato
5531ccb175 ALL: Massive 'const' cleanup
These changes facilitate more robust parameter type checking and helps
to identify unexpected coding errors.

Most simulators can now also be compiled with a C++ compiler without
warnings.

Additionally, these changes have also been configured to facilitate easier
backporting of simulator and device simulation modules to run under the
simh v3.9+ SCP framework.
2016-05-15 15:25:33 -07:00
Mark Pizzolato
4595525409 TIMER: Lower the minimum calibration stability value to 2 2016-01-28 06:49:14 -08:00
Mark Pizzolato
80595a532f TIMER: Properly define the timespec structure when building with newer MinGW.
From Dave Bryan.
2016-01-23 14:07:59 -08:00
Mark Pizzolato
de0d251c75 TIMER, SCP: Change the sim_activate_after APIs to pass the delay value as uint32.
Also change all sim_defs.h structure declarations and references of sim_
structures to use the typedef names everywhere.
2015-12-10 06:33:59 -08:00
Mark Pizzolato
ac9e19e250 TIMER: Add debug support for MUX clock co-scheduling 2015-12-08 16:56:34 -08:00
Mark Pizzolato
0938d31e59 PDP11, VAX: MUX input rate limiting works correctly with input arriving on multiple lines concurrently. 2015-11-28 12:49:54 -08:00
Mark Pizzolato
44ef17f971 TIMER: Fix recently revised sim_idle_capable for hosts which aren't idle capable. 2015-11-23 15:45:46 -08:00
Mark Pizzolato
15736aeec3 Visual Studio Projects: Added support for building under Visual Studio Community (2015)
Release build binaries built under Visual Studio Community DO NOT run on Windows XP.

Fix: #233
2015-08-19 11:16:47 -07:00
Mark Pizzolato
4eed007607 SCP: Restructured timer/co-scheduling activities to support co-scheduling on specific timers 2014-12-02 05:33:59 -08:00
Mark Pizzolato
2e85e74699 SCP: Various cleanups.
- Avoid assignments of void * values.  Cast all memory allocation return values to appropriate types.
- Add output to sim_log where missing in various places.
- Fixed issue with lost file positions after a restore for devices which leverage the UNIT_SEQ flag.
2013-11-20 09:13:27 -08:00
Mark Pizzolato
572ed3437a Optionally Enriched the info displayed at the beginning of debug message lines as discussed in Issue #66
sim> set debug -r -a -t -p somefile

    -a   produces seconds.msec time format
    -t    produces hh:mm:ss.msec time format
    -r    causes time values displayed to be relative to the wall clock time when the 'set debug' command was issued
    -r   by itself will cause default of -t

    -a and -t can both be specified if desired

    -p   adds display of current PC value to the debug timestamp output

sim> show debug
2013-07-15 04:38:54 -10:00
Mark Pizzolato
6cf54e8341 Fixes for stable operation with SIM_ASYNCH_CLOCKS defined 2013-05-07 11:22:29 -07:00
Mark Pizzolato
b31dc88d0d Added indication of idle/throttling capabilities and the OS clock tick size to the SHOW VERSION output 2013-03-14 11:37:31 -07:00
Mark Pizzolato
d5ca542102 Changed use of compile #defines which start with a _ character to not do this since defined symbols starting with _ are reserved to local compiler/runtime implementations in the C language. This addresses issue #32 2013-03-12 11:07:58 -07:00
Mark Pizzolato
eb101e3881 HP-UX port supplied by Mikulas Patocka 2013-03-05 13:29:38 -08:00
Mark Pizzolato
517e1e2bd1 Add display of the registered clock device 2013-01-22 16:05:02 -08:00
Mark Pizzolato
83c1d80194 Merge branch 'master' into AsyncTmxr
Conflicts merged and missing changes in new modules added as needed for clock co-scheduling.
2013-01-21 16:52:42 -08:00
Mark Pizzolato
4f19d08869 Initial merge of Asynchronous Multiplexer and Asynchronous Clock support 2013-01-17 11:34:51 -08:00
Mark Pizzolato
dac73b9381 Migrating scp and library global variables to be declared as extern in the appropriate library include file and remove repetitive declarations in referencing modules. 2013-01-10 13:29:15 -08:00
Mark Pizzolato
7c7df669ad Asynchronous Support
scp.c, scp.h
	- added sim_uname (Unit Name) API to simplify places which might want to display it (mostly debug messages).
	- added support for clock co-scheduling
	- added debugging to trace event queue activities

    sim_defs.h
	- added support for clock co-scheduling
	- added support for sim_uname (Thread local storage macro)
	- added support for debugging to trace event queue activities
	- simplified debug code by using sim_uname
	- fixed support macro for sim_is_active when asynch timers are in use

   sim_rev.h
	- fixed nested comments

    sim_tmxr.c, sim_tmxr.h
	- added support for clock co-scheduling
	- simplified debug code by using sim_uname
	- added support for devices which poll for output on different units

    sim_timer.c, sim_timer.h
	- added support for clock co-scheduling
	- fixed asynchronous clock calibration to smooth out calibration adjustments
	- simplified debug code by using sim_uname
	- added ability (when running with asynchronous support) to explicitly disable or enable asynchronous timer support.
	- changed sim_timer_inst_per_sec to return a double value since the result is always used in a double expression and integer overflow could occur under strange timing conditions

    vax/vax_stddev.c
	- converted from simulator specific clock co-scheduling to generic clock co-scheduling.

    vax/vax_cpu.c
	- added EVENT and ACTIVATE debug flag (SET CPU DEBUG=EVENT;ACTIVATE) support

    pdp11/pdp11_dz.c
	- converted from simulator specific clock co-scheduling to generic clock co-scheduling.

    pdp11/pdp11_vh.c
	- converted from simulator specific clock co-scheduling to generic clock co-scheduling.

    pdp11/pdp11_xq.c
	- converted from simulator specific clock co-scheduling to generic clock co-scheduling.
2012-11-12 15:33:35 -08:00
Mark Pizzolato
02cb620c9b Change to support serial ports on multiplexer devices without any changes to existing multiplexer device emulation code.
Added support for per line tcp listen ports.
Added support for per line outgoing tcp/telnet connections.

Removed DEV_NET from pdp11_dz and pdp11_vh emulators to allow proper restore of
2012-10-17 08:40:01 -07:00
Mark Pizzolato
030d790b4c Asynchronous Timer Support
scp.c, scp.h
	- Change the sim_clock_queue event list to be terminated by the value QUEUE_LIST_END instead of NULL.  This allows easy determination of whether a unit is on a list since when it is not on a list the next pointer is NULL.
	- standardized the usage of UPDATE_SIM_TIME
	- Added support for internal/pseudo devices to support the TIMER and CON-TEL pseudo devices (to enable and disable debugging)
	- Reverted to the prior "SET CONSOLE DEBUG" command semantics since the console debug can be manipulated via the generic "SET <dev> DEBUG" command (i.e. SET CON-TEL DEBUG=TRC;XMT;RCV)
	- Changed "SHOW TIMERS" to "SHOW CLOCKS" to display the current calibrated timer information
	- Added sim_is_active_bool API to return the boolean active status avoiding the potential work walking the list when most callers aren't interested in the event firing time
	- Fixed run_boot_prep to properly record the not queued status of any units which are removed from the sim_clock_queue during initialization
	- Added display of DEBUG, NODEBUG options to the SHOW SHOW command

    sim_timer.c, sim_timer.h
	- Added asynchronous timer capabilities with support for calibration and idling
	- Added internal/pseudo device to support debugging of Idle, Calibration and asynch timer activites.
	- Added suppression of timer calibration when idling has occurred

    sim_tmxr.c, sim_tmxr.h
	- Added tmxr_activate_after and macro definition for sim_activate_after to invoke it for proper behavior with multiplexer devices
	- Added all polling units to the standard timer queue when dropping back to the simulator command prompt to accommodate the potential to disable asynch mode
	- Fixed synchronization to operate with pthread synchronized asynch queue and proper stopping of poll when dropping back to the simulator command prompt
	- Fixed calls to select to have a timeout with properly ranged tv_usec values and dealt with possible EINTR return from select

    sim_console.c, sim_console.h
	- Changed internal/pseudo console telnet device name to CON=TEL
	- Reverted to the prior "SET CONSOLE DEBUG" command semantics since the console debug can be manipulated via the generic "SET <dev> DEBUG" command (i.e. SET CON-TEL DEBUG=TRC;XMT;RCV)
	- Fixed synchronization to operate with pthread synchronized asynch queue and proper stopping of poll when dropping back to the simulator command prompt
	- Fixed calls to select to have a timeout with properly ranged tv_usec values

    sim_defs.h
	- Added necessary unit fields to support asynchronous timing activities
	- Added asynchronous macros to support async timing activities
	- Fixed asynch pthread only macros (not using AIO_INTRINSICS).
	- Fixed the definition of the UDATA macro which was never adjusted to accommodate the insertion of 2 extra fields in the unit structure and thus made the initialization of the unit wait field meaningless.
	- Changed the NOQUEUE_WAIT value from 10000 to 1000000.  This is only used when the sim_clock_queue is empty, which normally never happens on any simulator since they all have clocks and/or other frequently polling devices.  With asynchronous multiplexer and timing support the queue is often empty and this value is then used when calculating idling delays.  If it is too small, idling will be inefficient.  Being large should not be a problem otherwise.

    Interdata/id16_cpu.c
	- removed test of sim_idle_enab before calling sim_idle

    Interdata/id32_cpu.c
	- removed test of sim_idle_enab before calling sim_idle

    vax/vax_cpu.c
	- removed test of sim_idle_enab before calling sim_idle

    vax/vax_stddev.c
	- converted CLK device to use the internal timer service API sim_activate_after to leverage asynchronous timing when available
2012-05-26 07:16:04 -07:00
Mark Pizzolato
7c38b83d7c Asynchronous Multiplexer and Console Support
scp.c, scp.h, sim_defs.h
     - Added commands:
          SHOW MULTIPLEXER (MUX)
          SHOW TIMERS
     - Added facilities/APIs:
          sim_activate_after - time specific event scheduling (vs instruction scheduling) API visible, optional separate thread implementation in a later revision
     - Changed Commands:
          SET CONSOLE DEBUG no longer affects global debugging, but merely debugging for the console subsystem.  Use SET DEBUG and SET NODEBUG to affect global debugging.
     - Added Asynchronous polling support

sim_tmxr.h, sim_tmxr.c
     - Added Asynchronous capabilities to the multiplexer subsystem to avoid polling for input and to deliver input data instantly when it arrives instead of delaying for up to one or more full simulated clock ticks.
     - Added debug trace support
     - Added statistic tracking of total bytes transmitted on each line
     - Added more aggressive attempts to flush transmit buffers when they fill before dropping tranmitted characters
     - Fixed status return of tmxr_putc_ln to return SCPE_LOST if the transmitting line isn't connected or buffered.

sim_console.h, sim_console.c
     - Fixed issue where connections to console telnet sessions would succeed for the first connection, but hang indefinitely for additional connects without rejecting due to all lines being busy.  This is handled by using an internal device and unit to hang the required polling on.  Connection polls happen once per second.
     - Added console debugging/trace support.
     - Added Asynchronous capabilities to the console subsystem to avoid polling for input and to deliver input data instantly when it arrives instead of delaying for up to one or more full simulated clock ticks.
     - Added tmxr_set_console_input_unit() API to support asynchronous simulator console I/O

sim_timer.h, sim_timer.c
     - Added SHOW TIMERS support
     - Added mechanism to capture the timer the simulator uses for its clock tick and make this timer globally available for other uses

PDP11/pdp11_dz.c
     - Added debug trace support

PDP11/pdp11_vh.c
     - Added debug trace support
     - Changed timing mechanisms to not assume that the count unit service routine calls measures the passage of time, and created a separate unit to measure time.

VAX/vax_stddev.c
     - Added call to tmxr_set_console_input_unit to leverage Asynchronous console I/O
2012-05-12 13:42:44 -07:00
Mark Pizzolato
d4c83e5f46 Make sure that the correct struct timespec definition (which the pthreads APIs will need) is known before we define our own. 2012-01-13 15:32:51 -08:00
Mark Pizzolato
1d490907ad Fix for OSX clean compile 2011-11-02 14:54:00 -07:00
Mark Pizzolato
bfb6e54819 Compiler warning cleanup 2011-10-31 10:26:58 -07:00
Mark Pizzolato
c38eacd0c8 Fixed throttling in several ways:
- Sleep for the observed clock tick size while throttling
                        - Recompute the throttling wait once every 10 seconds
                          to account for varying instruction mixes during
                          different phases of a simulator execution or to
                          accommodate the presence of other load on the host
                          system.
                        - Each of the pre-existing throttling modes (Kcps,
                          Mcps, and %) all compute the appropriate throttling
                          interval dynamically.  These dynamic computations
                          assume that 100% of the host CPU is dedicated to
                          the current simulator during this computation.
                          This assumption may not always be true and under
                          certain conditions may never provide a way to
                          correctly determine the appropriate throttling
                          wait.  An additional throttling mode has been added
                          which allows the simulator operator to explicitly
                          state the desired throttling wait parameters.
                          These are specified by:
                                 SET THROT insts/delay
                          where 'insts' is the number of instructions to
                          execute before sleeping for 'delay' milliseconds.
2011-10-25 03:52:24 -07:00
Mark Pizzolato
5687f9227b VAX & VAX780 Generalized setting TODR for all OSes.
Unbound the TODR value from the 100hz clock tick interrupt.  TODR now behaves like the original battery backed-up clock and runs with the wall clock, not the simulated instruction clock (except when running ROM diagnostics).

Two operational modes are available:
    - Default VMS mode, which is similar to the previous
      behavior in that without initializing the TODR it
      would default to the value VMS would set it to if
      VMS knew the correct time.  This would be correct
      almost all the time unless a VMS disk hadn't been
      booted from for more than a year.  This mode
      produces strange time results for non VMS OSes on
      each system boot.
    - OS Agnostic mode.  This mode behaves precisely like
      the VAX780 TODR and works correctly for all OSes.
      This mode is enabled by attaching the TODR to a
      battery backup state file for the TOY clock
      (i.e. sim> attach TODR TOY_CLOCK).  When operating
      in OS Agnostic mode, the TODR will initially start
      counting from 0 and be adjusted differently when an
      OS specifically writes to the TODR.  VMS will prompt
      to set the time on the initial boot unless the SYSGEN
      parameter TIMEPROMPTWAIT is set to 0.
2011-09-29 06:18:49 -07:00
Bob Supnik
9c4779c061 Notes For V3.8
The makefile now works for Linux and most Unix's. Howevr, for Solaris
and MacOS, you must first export the OSTYPE environment variable:

> export OSTYPE
> make

Otherwise, you will get build errors.

1. New Features

1.1 3.8-0

1.1.1 SCP and Libraries

- BREAK, NOBREAK, and SHOW BREAK with no argument will set, clear, and
  show (respectively) a breakpoint at the current PC.

1.1.2 GRI

- Added support for the GRI-99 processor.

1.1.3 HP2100

- Added support for the BACI terminal interface.
- Added support for RTE OS/VMA/EMA, SIGNAL, VIS firmware extensions.

1.1.4 Nova

- Added support for 64KW memory (implemented in third-party CPU's).

1.1.5 PDP-11

- Added support for DC11, RC11, KE11A, KG11A.
- Added modem control support for DL11.
- Added ASCII character support for all 8b devices.

1.2 3.8-1

1.2.1 SCP and libraries

- Added capability to set line connection order for terminal multiplexers.

1.2.2 HP2100

- Added support for 12620A/12936A privileged interrupt fence.
- Added support for 12792C eight-channel asynchronous multiplexer.

2. Bugs Fixed

Please see the revision history on http://simh.trailing-edge.com or
in the source module sim_rev.h.
2011-04-15 08:35:54 -07:00