[Simh] idling documentation??

Mark Martinec Mark.Martinec+simh at ijs.si
Mon Dec 20 11:19:34 EST 2010


> i dont understand how the idle parts work, anybody have any documentation?
> why cant we just do it like the how i did it below. aside from the
> side effect that the system clock of guest os loooses track, it seems
> to work ok. From what i can see from the code idle only works for VAX
> and few others, not PDP11

It doesn't even work for VAX on reasonably fresh hw, it says:
  sim> set cpu idle
  Command not allowed
when host's clock resolution as stored to sim_idle_rate_ms
by sim_timer_init() is below 1 ms, and the simh treats it
as an error condition  (using simh-3.8.1).

The following program (based on what was posted here some time ago)
illustrates how the msec gets a value of 0:

#include <time.h>
#include <stdio.h>
#define NANOS_PER_MILLI 1000000
int main(int argc, char **argv) {
  struct timespec treq;
  if (clock_getres(CLOCK_REALTIME, &treq)) {
    perror("clock_getres error");
  } else {
    int msec = (treq.tv_nsec + (NANOS_PER_MILLI >> 1)) / NANOS_PER_MILLI;
    double fmsec = (double)treq.tv_nsec / NANOS_PER_MILLI;
    printf ("Clock resolution: %d msec, %.6f msec, %ld.%09ld nanoseconds\n",
       msec, fmsec, treq.tv_sec, treq.tv_nsec);
  }
}

# sysctl kern.timecounter.hardware=HPET
$ ./test
Clock resolution: 0 msec, 0.000070 msec, 0.000000070 nanoseconds

# sysctl kern.timecounter.hardware=ACPI-fast
$ ./test
Clock resolution: 0 msec, 0.000280 msec, 0.000000280 nanoseconds

# sysctl kern.timecounter.hardware=i8254
$ ./test
Clock resolution: 0 msec, 0.000839 msec, 0.000000839 nanoseconds

No clock source exists on this system (FreeBSD 8.1, i7 CPU)
that would yield a clock resolution above 1 ms.

Looks to me like the timing routines in simh need an overhaul.


I wonder if msec==0 also explains another anomaly (running VMS V5.5-2),
namely that after a guest is left idling for a while, it becomes unresponsive,
and comes back to life in dozens of seconds after typing any command
or just a CR on a command prompt.

  Mark



More information about the Simh mailing list