Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set cpu idle return "Command not allowed" in NetBSD-5.1.2 #1

Closed
credmon opened this issue Apr 11, 2012 · 4 comments
Closed

set cpu idle return "Command not allowed" in NetBSD-5.1.2 #1

credmon opened this issue Apr 11, 2012 · 4 comments

Comments

@credmon
Copy link

credmon commented Apr 11, 2012

The command "set cpu idle" returns "Command not allowed" in NetBSD-5.1.2. This previously worked on V3.8-1 when using the posix compliant implementation of sim_os_ms_sleep_init.

% uname -a
NetBSD fx 5.1.2 NetBSD 5.1.2 (GENERIC) #0: Thu Feb 2 12:12:28 UTC 2012 builds@b7.netbsd.org:/home/builds/ab/netbsd-5-1-2-RELEASE/amd64/201202021012Z-obj/home/builds/ab/netbsd-5-1-2-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64
% ./pdp11

PDP-11 simulator V3.9-0
sim> set cpu idle
Command not allowed
sim>

@markpizz
Copy link
Member

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.

@credmon
Copy link
Author

credmon commented Apr 11, 2012

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

@markpizz
Copy link
Member

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.

@markpizz
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants