[Simh] idle feature

Bailey, Scott scott.bailey at eds.com
Fri Feb 8 15:45:10 EST 2008


Mark, I tried your program.

On my system (AMD Athlon 64 dual core 4200+, Debian's
linux-image-2.6.24-1-amd64), I get:

Close Resolution: 0 msec, 1 nanoseconds

Looking at sim_timer.c, I see the test you are talking about... But of
course, it appears that "0" [msec] is overloaded to mean that
sim_os_ms_sleep_init() failed and I presume that idle support is
thereafter disabled. :-) Evidently high-resolution clock support is not
always a good thing!

I hacked the code at this point [sim_timer.c, line 306] to replace:

	return msec;

with

	if (msec)
	    return msec;
	else
	    return 1;

and that seems to have magically enabled the set cpu idle command again.
I haven't fired up the simulator yet to see if it really seems to be
WORKING or not yet, but I am hoping that using an interval higher than
what the system supports won't be a problem.

Advice on whether this is the smartest thing to do -- i.e., would it be
more effective to use a higher value and avoid thrashing the timer? --
would be appreciated.

Thanks,

	Scott

-----Original Message-----
From: simh-bounces at trailing-edge.com
[mailto:simh-bounces at trailing-edge.com] On Behalf Of Mark Pizzolato
Sent: Friday, February 08, 2008 11:37 AM
To: SIMH Mailing List
Subject: Re: [Simh] idle feature

[...]

The simulator uses clock_getres() to determine the size of the clock
tick.  It then performs the following calculation to determine the
size of the tick in milliseconds:
msec = (treq.tv_nsec + (NANOS_PER_MILLI >> 1)) / NANOS_PER_MILLI;
this should round the number of nanoseconds up to the closest
millisecond and come up with the millisecond value.  If the result is
greater than 10, then idling is disabled.

I don't know of a command line program which calls and displays
clock_getres(), but you could compile the below one.  Once you have
that you can test to see if the "adjtimex -t 9999" changes the value
returned by clock_getres().

#include <time.h>
#include <stdio.h>
#define NANOS_PER_MILLI     1000000
main(int argc, char **argv)
{
struct timespec treq;
uint32 msec;

clock_getres (CLOCK_REALTIME, &treq);
msec = (treq.tv_nsec + (NANOS_PER_MILLI >> 1)) / NANOS_PER_MILLI;
printf ("Close Resolution: %d msec, %d nanoseconds\n", msec,
treq.tv_nsec);
}



More information about the Simh mailing list