[Simh] idle feature
Seth Morabito
sethm at loomcom.com
Fri Feb 8 23:02:01 EST 2008
On Feb 8, 2008, at 4:17 PM, Mark Pizzolato wrote:
> So on your system the clock_getres() API seems to be failing. Since
> my test program didn't check the return status from clock_getres() it
> proceeded to perform calculations on the random uninitialized stack
> variable, so the output was meaningless.
I'm experiencing the same problems with SET IDLE on my system (Ubuntu
7.10, compiled with -lrt). Even after I patched your little test
program to check the return status of clock_getres(), I'm getting the
same output as Scott Bailey.
Here's the revised program (man clock_getres states that
"clock_gettime(), clock_settime() and clock_getres() return 0 for
success, or -1 for failure (in which case errno is set
appropriately)."):
#include <time.h>
#include <errno.h>
#include <stdio.h>
#define NANOS_PER_MILLI 1000000
int main(int argc, char **argv) {
struct timespec treq;
unsigned long int msec;
int result;
if (clock_getres(CLOCK_REALTIME, &treq) != -1) {
msec = (treq.tv_nsec + (NANOS_PER_MILLI >> 1)) /
NANOS_PER_MILLI;
printf("Close Resolution: %d msec, %d nanoseconds\n", msec,
treq.tv_nsec);
} else {
perror("clock_getres failed");
}
}
Compiled with 'gcc -lrt -o clocktest' I get the following output:
Close Resolution: 0 msec, 1 nanoseconds
Very odd!
-Seth
More information about the Simh
mailing list