From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,6266f9f777efcf2d X-Google-Attributes: gid1164f8,public X-Google-Thread: 102b08,6266f9f777efcf2d X-Google-Attributes: gid102b08,public X-Google-Thread: 10996c,18ddcd59ce65fa67,start X-Google-Attributes: gid10996c,public X-Google-Thread: f4871,6266f9f777efcf2d X-Google-Attributes: gidf4871,public X-Google-ArrivalTime: 1994-01-21 16:33:19 PST Xref: gmd.de comp.sys.sun.apps:6736 comp.sys.hp.misc:685 comp.parallel.pvm:1306 comp.sys.dec:13014 Path: gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!uunet!auspex-gw!guy From: guy@Auspex.COM (Guy Harris) Newsgroups: comp.sys.sun.apps,comp.sys.hp.misc,comp.parallel.pvm,comp.sys.dec Subject: Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) Message-ID: <19677@auspex-gw.auspex.com> Date: 21 Jan 94 19:25:18 GMT References: <2hmq76INNd2e@flop.ENGR.ORST.EDU> Sender: news@auspex-gw.auspex.com Followup-To: comp.sys.sun.apps Organization: Auspex Systems, Santa Clara Nntp-Posting-Host: bootme.auspex.com >gettimeofday(2) only returns the operating system's idea of time. I think that >he is looking for code fragments on how to read the Real Time Clock >chip. Hopefully, HP-UX's "gettimeofday()" code in the kernel reads the high-resolution clock, given the suggestion to use "gettimeofday()" on HP machines; SunOS's "gettimeofday()" code has done that since SunOS 4.1. However, that usually involves a trip into the kernel, so the time you get back may not be the time that you made the call. If so, and if that's not acceptable, you would have to try to read the clock yourself. >I >don't have this info but, there is a header file, /usr/include/sun4/clock.h, >that describes the layout of various chips used by Sun. Or, at least, on machines with the "sun4" kernel architecture - the machines with that kernel architecture, and with high-resolution clocks, are the SPARCsystem 3xx and SPARCsystem 4xx machines. Check out "struct counterregs". All machines with "sun4c", "sun4m", "sun4e", and, I suspect, "sun4d" kernel architectures have high-resolution clocks. On "sun4c" machines, check out "/usr/include/sun4c/clock.h"; again, check out "counterregs". On "sun4m" machines, check out "counterregs" in "/usr/include/sun4m/counter.h". All that's for SunOS 4.x. SunOS 5.x doesn't have the relevant header files in any obvious place (and no 4.x release runs on "sun4d" machines). >You probably need >this header file and then you probably need to call either ioctl(2) or mmap(2) >to read/write the chip, just guessing though. No "ioctl" exists to let you read the chip; besides, it's a system call, so you don't win over using "gettimeofday()". It might be possible to "mmap()" the clock in; you'd have to know its physical address and map that in, *probably* from "/dev/obio". I can't speak for HP or DEC machines, although they don't necessarily make it any easier to get at the high-resolution clocks from user mode than Sun machines do - they might, though.