GetTimeOfDay Function

GetTimeOfDay Function

Post by mathew gaha » Thu, 31 Oct 1996 04:00:00



Has anybody out there had any use the GetTimeOfDay()/Settimeofday()
functions on Sparc's SVR4 as I have had no luck in my attemts to use
them. I am tring to extract time stamps down to tenths of a second and I
believe that Gettimeofday can resolve to 100th's of a second. If anybody
knows the solution to this problem please could you help me. Here's
hopeing.
--
mathew gahan
Sentient Developments Ltd.

Turnpike evaluation. For information, see http://www.turnpike.com/

 
 
 

GetTimeOfDay Function

Post by Casper H.S. D » Thu, 31 Oct 1996 04:00:00



>Has anybody out there had any use the GetTimeOfDay()/Settimeofday()
>functions on Sparc's SVR4 as I have had no luck in my attemts to use
>them. I am tring to extract time stamps down to tenths of a second and I
>believe that Gettimeofday can resolve to 100th's of a second. If anybody
>knows the solution to this problem please could you help me. Here's
>hopeing.

gettimeofday() [not the lowercase] should work fine and has in fact
microsecond resolution on hardware that supports it.

What have you tried and what didn't work?

Casper
--
Casper Dik - Sun Microsystems - via my guest account at the University

Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

1. UNIX - C - gettimeofday function

I'm new to UNIX and C and am having difficulty with the gettimeofday
function.  I understand that a time structure and time zone structure are
created and then a pointer is assigned them.  These pointers are then
passed into the function, the function "loaded" the pointer location with
the appropriate data and then control is passed to the program that called
it.   (did I get this much right?)  The folowing is my code and the output
it produces.  I'm doing several things in this code to assist me in
understanding the C language.  Here is the code:

#include <stdio.h>
#include <sys/time.h>

main()
{
        int var1 = 11;
        int var2 = 22;
        int var3 = 33;

        struct timeval *tp;
        struct timezone *tpz;

        printf("var1 is: %d.\n", &var1);
        printf("var2 is: %d.\n", &var2);
        printf("var3 is: %d.\n", &var3);

        gettimeofday(tp, tpz);

        printf("&tp is: %d.\n", &tp);
        printf("&tpz is: %d.\n", &tpz);
        printf("&tp->tv_sec is: %d.\n", &tp->tv_sec);
        printf("&tp->tv_usec is: %d.\n", &tp->tv_usec);
        printf("tp is: %i.\n", tp);
        printf("tpz is: %i.\n", tpz);
        printf("tp->tv_sec is: %i.\n", tp->tv_sec);
        printf("*tp is: %i.\n", *tp);
        printf("*tpz is: %i.\n", *tpz);
        return 0;

The output is produces is as follows:

var1 is: 67108016.
var2 is: 67108012.
var3 is: 67108008.
&tp is: 67108004.
&tpz is: 67108000.
&tp->tv_sec is: 84531170.
&tp->tv_usec is: 84531174.
tp is: 84531170.
tpz is: 65820.
tp->tv_sec is: 1835100526.
*tp is: 1835100526.
*tpz is: 0.

My understanding is that I was supposed to get "time of day in seconds"
passed since 1-1-97, which I calculated to be about 852,000,000 seconds.  I
don't see that showing up here at all.  What am I doing wrong??  I would
really appreciate it if someone could help.   Thanks, Chuck Hekman.

2. PLIP driver for Windoze 95?

3. gettimeofday function

4. Apache 1.3.3 & Servlet: Strange Timeout?

5. Problem linking to gettimeofday function

6. Dynamic libraries and parameters

7. Problem with gettimeofday() function

8. 2 in 1 different BIND responses for internal and external networks

9. standard C gettimeofday function

10. gettimeofday(struct timeval *tp) but is in 2.4 gettimeofday(tp,tzp)

11. How to use "gettimeofday" function

12. gettimeofday system function giving bad system call coredump

13. function, function...who's got the function?