[Simh] Simulating power fail
Mark Pizzolato
Mark at infocomm.com
Fri Sep 7 12:37:28 EDT 2018
On Friday, September 7, 2018 at 1:18 AM, Lars Brinkhoff wrote:
> Timothe Litt wrote:
> > Adding an API in the CPU of the form assert_powerfail( vector) - where
> > the default is the usual 24/26, but a ROM can specify an alternate
> > (usually its base address + 24/26). This is common to all initiators.
>
> This touches on something else I have been thinking about.
>
> Would it be appropriate to have a SIGTERM (and/or similar signals) trigger a
> power fail in the PDP-11 and other simulators with corresponding
> mechanisms? SIGINT goes into the SCP console, and of course SIGKILL instantly
> switches off the simulated machine.
>
> The use case I have in mind is scripted start and stop of SIMH.
> Starting would capture the pid. Stopping could first send a SIGTERM, wait a
> few seconds, and then kill the process.
Currently SIGINT and SIGTERM both will bring a simulator to the sim> prompt
(or the next input when running in the context of a simh command file). Code
in that command file can readily manipulate details of the simulator state.
These manipulations might set the simulator internal variables to trigger a
Power fail interrupt when simulation execution continues, but it's not clear
what might get done in the simulator in response to that given the simulator
will be killed very shortly. If this is really what you want, nothing needs to
be changed in simh to achieve this beyond writing script to do this for the
particular simulator you're running.
Alternatively, I've got a simulator that's been running via a script in a
background process for 10+ years. The script it is running under receives
one of these signals and that immediately drops out of sim_instr() and the
script is configured to SAVE the simulator state to a file. When the simulator
starts, if the SAVEd file exists, it is RESTOREd and execution continues. The
OS in the simulator is none the wiser that its host had, for some reason, taken
a break. The time of day in the simulator is off, but various methods exist
(NTP, or reload the time from the simulated hardware TODR) to dynamically
adjust for that. This works well since the SAVE operation takes well less than
a second which is a reasonable time for the host system's shutdown to wait
for a process to exit, while other things inside the simulator might take
indeterminate amounts of time, and the state they were in prior to
receiving the SIGINT/SIGTERM would be lost. The script in question is
completely made up of simh commands.
- Mark
More information about the Simh
mailing list