Giter VIP home page Giter VIP logo

Comments (4)

markpizz avatar markpizz commented on August 19, 2024

The prior implementation (when compiled with _POSIX_SOURCE) used the clock_getres API. This strategy was flawed since the clock_getres API returns the "UNITS" of the clock resolution. These value of the 'units' aren't what is important for a reliable idle implementation. What is important is smallest amount of time you can actually sleep when calling nanosleep() (or whatever platform specific sleep mechanism is available).

The new strategy measures the minimum sleep time. This measurement is correct and the simulator will behave as designed, and simulated time will track real time as close as possible.

For all platforms, if the minimum sleep time is greater than SIM_IDLE_MAX (which is 10ms), then the assumptions in the idle code can't produce reliable results. The closer the minimum sleep time gets to SIM_IDLE_MAX, the more erratic the progress of time (within the simulator) will appear when compared to wall clock time. Once SIM_IDLE_MAX is exceeded things can't be predicted or corrected.

On my test NetBSD 5.1 system, the clock tick (sleep resolution) appears to be 20ms, so I see the failure here as well.

If you can convince your OS to run with a shorter clock tick (and hence have a finer grained sleep resolution), then the simh idling implementation will work just fine. Some operating systems allow this value to be configured or even programmatically manipulated. If you can provide a programmatic way to influence the sleep resolution (or a better sleep implementation), we'll be glad to integrate its use. All modern hardware can have system clock ticks which are sufficiently small to provide reliable simh idling.

Alternatively, if having simulated time have any useful relationship to real time is not important to you, you can continue to use idling on the older simh version.

I have checked in code on the master branch which will report why idling isn't available due to minimum sleep resolution constraints and to display the available minimum OS sleep time.

from simh.

credmon avatar credmon commented on August 19, 2024

Thanks for the info Mark. You are seeing exactly what I am seeing.

from simh.

markpizz avatar markpizz commented on August 19, 2024

Please come back and let us know if you come up with a better sleep implementation or have a way to influence the host clock tick size. Even if it involves rebuilding a kernel. The details of how to do this may be useful to others. I'm closing this now.

from simh.

markpizz avatar markpizz commented on August 19, 2024

This issue also comes up on Solaris host systems. Info suggests that changing /etc/system to contain the following lines will be sufficient to provide a 1ms host tick on Solaris hosts.

set hires_tick=1
set hires_hz=1000

The changed setting will take effect after the Solaris host system is rebooted.

from simh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.