* Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) @ 1994-01-20 20:40 NeoSwami 1994-01-20 21:42 ` Paul Gootherts 1994-01-21 16:59 ` Bart Smaalders 0 siblings, 2 replies; 13+ messages in thread From: NeoSwami @ 1994-01-20 20:40 UTC (permalink / raw) Hi, We are porting an instrumentation library from ibms to other workstations. We have an assembly language timer routine which is passed an array of two longs/ints and when it returns, the 1st element contains no. of whole seconds since 00:00 UCT 1 January 1970. 2nd element contains fractional seconds since last second We are looking for a similar kind of routine for the following workstations: Sun Sparcs 1-10. HP 700 series [715/730] Dec alpha workstations. Any information/code is appreciated. If you are interested in looking at the ibm rs6k's code send me a mail. thank you very much, unBeing. [padalam@cs.orst.edu] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-20 20:40 Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) NeoSwami @ 1994-01-20 21:42 ` Paul Gootherts 1994-01-21 12:23 ` Kell S|nnichsen ` (2 more replies) 1994-01-21 16:59 ` Bart Smaalders 1 sibling, 3 replies; 13+ messages in thread From: Paul Gootherts @ 1994-01-20 21:42 UTC (permalink / raw) NeoSwami (padalam@research.CS.ORST.EDU) wrote: > We are looking for a similar kind of routine for the following workstations: > ... > HP 700 series [715/730] > ... Take a look at gettimeofday(2). Paul Gootherts pdg@cup.hp.com ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-20 21:42 ` Paul Gootherts @ 1994-01-21 12:23 ` Kell S|nnichsen 1994-01-21 15:48 ` john.j.rushford..jr 1994-01-24 17:12 ` Benjamin Z. Goldsteen 2 siblings, 0 replies; 13+ messages in thread From: Kell S|nnichsen @ 1994-01-21 12:23 UTC (permalink / raw) Thus spake pdg@cup.hp.com (Paul Gootherts): >NeoSwami (padalam@research.CS.ORST.EDU) wrote: >> We are looking for a similar kind of routine for the following workstations: >> ... >> HP 700 series [715/730] >> ... >Take a look at gettimeofday(2). Ditto for Sun Sparcs >Paul Gootherts >pdg@cup.hp.com /Kell -- _/ Kell S|nnichsen _/_/_/_/ The two most abundant things in _/ _/ Computer Science Dept. _/_/_/_/ the Universe are Hydrogen and _/ _/ University of Aarhus, Denmark _/_/_/_/ stupidity. _/ _/ email: kells@daimi.aau.dk _/_/_/_/ -- Harlan Ellison. _/ ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-20 21:42 ` Paul Gootherts 1994-01-21 12:23 ` Kell S|nnichsen @ 1994-01-21 15:48 ` john.j.rushford..jr 1994-01-21 19:25 ` Guy Harris 1994-01-24 17:12 ` Benjamin Z. Goldsteen 2 siblings, 1 reply; 13+ messages in thread From: john.j.rushford..jr @ 1994-01-21 15:48 UTC (permalink / raw) In article <CJy6yC.B1K@cup.hp.com> pdg@cup.hp.com (Paul Gootherts) writes: >NeoSwami (padalam@research.CS.ORST.EDU) wrote: >> We are looking for a similar kind of routine for the following workstations: >> ... >> HP 700 series [715/730] >> ... > >Take a look at gettimeofday(2). > >Paul Gootherts >pdg@cup.hp.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. 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. 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. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-21 15:48 ` john.j.rushford..jr @ 1994-01-21 19:25 ` Guy Harris 0 siblings, 0 replies; 13+ messages in thread From: Guy Harris @ 1994-01-21 19:25 UTC (permalink / raw) >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. ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-20 21:42 ` Paul Gootherts 1994-01-21 12:23 ` Kell S|nnichsen 1994-01-21 15:48 ` john.j.rushford..jr @ 1994-01-24 17:12 ` Benjamin Z. Goldsteen 1994-01-25 8:08 ` Bart Smaalders 2 siblings, 1 reply; 13+ messages in thread From: Benjamin Z. Goldsteen @ 1994-01-24 17:12 UTC (permalink / raw) pdg@cup.hp.com (Paul Gootherts) writes: >NeoSwami (padalam@research.CS.ORST.EDU) wrote: >> We are looking for a similar kind of routine for the following workstations: >> ... >> HP 700 series [715/730] >> ... >Take a look at gettimeofday(2). >Paul Gootherts >pdg@cup.hp.com I think a number of people have said this but am guessing that there is not enough resolution in it. I don't remember what type of instrumentation he said he was doing but the time to do a typical system call will overwhelm what one can get from a real-time clock. The IBM RS/6000 clock he was referring to is accessible by a few assembly language instructions and offers microsecond precision: > Newsgroups: comp.unix.aix > Path: rex!constellation!convex!convex!cs.utexas.edu!uunet!newsgate.watson.ibm.com!yktnews.watson.ibm.com!yktnews!prener > From: prener@watson.ibm.com (Dan Prener) > Subject: Re: Memory mapped clock > Sender: news@yktnews.watson.ibm.com (NNTP News Poster) > Message-ID: <PRENER.93May31015847@prener.watson.ibm.com> > In-Reply-To: gerth@watson.ibm.com's message of Fri, 28 May 1993 14:14:44 GMT > Date: Mon, 31 May 1993 06:58:47 GMT > Disclaimer: This posting represents the poster's views, not necessarily those of IBM. > References: <0E062001.2iihl1@anubis.han.de> <C7qq8K.rws@hawnews.watson.ibm.com> > Nntp-Posting-Host: prener.watson.ibm.com > Organization: IBM T.J. Watson Research Center, Hawthorne, New York > Lines: 39 > > In article <C7qq8K.rws@hawnews.watson.ibm.com> gerth@watson.ibm.com (John Gerth) writes: > > [ ... ] > > > The real-time clock on the S/6000 is readable from a user-level program. > > You need to actually do the reading in an assembler routine (there are > > a couple of good publications which show this in detail - GG24-3633 AIX > > Version 3 as a Real-Time System" and GG24-3711 "Predicting Execution Time > > on the IBM Risc System/6000"). The clock consists of two 32-bit integer > > words - one with seconds, the other with nanonseconds, i.e. if you combine > > the two you can get a double with resolution much finer than the "clock tick". > > > Here's the meat of the assembler (I'm not providing any housekeeping): > > .rtc_upper: > > .globl .rtc_upper > > mfspr 3,4 > > br > > .rtc_lower: > > .globl .rtc_lower > > mfspr 3,5 > > br > > These would be used as follows: > > double time_in_seconds(){ > > double tl,tu; > > tu = rtc_upper(); > > tl = rtc_lower(); > > return (tu + (tl/1000000000)); > > } > > A more robust approach is to read the upper half of the clock, then read the > lower half, then read the upper half again. If the two reads of the upper > half are different, discard the whole thing and start over, since you cannot > be sure that the lower-half reading corresponds to a given one of the > upper-half readings. > > According to your taste, this entire process could be incorporated in > a single assembler routine, or wrapped around the two routines above. > -- > Dan Prener (prener@watson.ibm.com) P.S.Not picking on you, but I have yet to see the right answer and I don't really believe no other UNIX offers better than millisecond resolution. My apologies if HP's gettimeofday(2) is considerably faster and more precise than other UNIX's... -- Benjamin Z. Goldsteen ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-24 17:12 ` Benjamin Z. Goldsteen @ 1994-01-25 8:08 ` Bart Smaalders 1994-01-25 18:42 ` Bob Manchek ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Bart Smaalders @ 1994-01-25 8:08 UTC (permalink / raw) <Someone is looking for a hardware timer and doesn't believe Solaris 2.[23] gettimeofday is adequate> Gettimeoday(2) is implemented as a fast trap since Solaris 2.2. As a result, this call takes about 2->3 microseconds on a SS10 (slightly more on an SS2). It returns answers accurate to the resolution of the hardware clock (1 microsecond on 4[cmd] platforms). Please remember to allow for clock ticks when interpreting data obtained via this call. In addition, any skewing of the clock to adjust time gradually will appear in these values. Since one test is often worth 1000 expert opinions, I wrote a small program to make 10000 calls in a loop to gettimeofday, and afterward computed min time between samples and mean time between samples. I ran it until I missed the clock ticks and other apps. All times in seconds. On SS10 M51 running the next release of Solaris: min = .000002, mean = .000003 On HP 9000/755 running HP-UX A.09.01 C: min = .000017, mean = .000021 I've forgotten the orignal thread, but this should probably be adequate for most purposes. Remember that these clocks are often slow to read in hardware, let alone software. - Bart Smaalders CDE performance My opinions, etc..... ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-25 8:08 ` Bart Smaalders @ 1994-01-25 18:42 ` Bob Manchek 1994-01-26 0:57 ` Doug Siebert 1994-01-29 5:07 ` mark hahn 2 siblings, 0 replies; 13+ messages in thread From: Bob Manchek @ 1994-01-25 18:42 UTC (permalink / raw) Here's a cheezy little program from back when I was writing the networking code. Just compile and run... /* * clockgran.c * * Demonstrate the granularity of the clock by sampling it * as fast as we can and saving the deltas. * * 10 Dec 1991 Manchek */ #include <stdio.h> #include <time.h> #include <sys/time.h> main() { struct timeval t1, t2; int del[200]; int i; gettimeofday(&t1, (struct timezone*)0); for (i = 0; i < 200; i++) { do { gettimeofday(&t2, (struct timezone*)0); } while (t2.tv_sec == t1.tv_sec && t2.tv_usec == t1.tv_usec); del[i] = (t2.tv_sec - t1.tv_sec) * 1000000 + t2.tv_usec - t1.tv_usec; t1 = t2; } for (i = 0; i < 200; i++) { printf("%8d", del[i]); } puts(""); exit(0); } -- / Robert Manchek University of Tennessee / / Computer Science Department / / (615)974-8295 Ayres Hall #104 / / manchek@CS.UTK.EDU. Knoxville TN 37996-1301 / ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-25 8:08 ` Bart Smaalders 1994-01-25 18:42 ` Bob Manchek @ 1994-01-26 0:57 ` Doug Siebert 1994-01-26 8:11 ` Casper H.S. Dik 1994-01-27 4:07 ` Greg Limes 1994-01-29 5:07 ` mark hahn 2 siblings, 2 replies; 13+ messages in thread From: Doug Siebert @ 1994-01-26 0:57 UTC (permalink / raw) barts@cyber.Eng.Sun.COM (Bart Smaalders) writes: ><Someone is looking for a hardware timer and doesn't believe Solaris 2.[23] > gettimeofday is adequate> >Gettimeoday(2) is implemented as a fast trap since Solaris 2.2. As a result, >this call takes about 2->3 microseconds on a SS10 (slightly more on an SS2). >It returns answers accurate to the resolution of the hardware clock (1 microsecond >on 4[cmd] platforms). Could someone explain to me exactly WHY this has to be a system call at all? It seems to me it would make a GREAT deal of sense to map things like the hardware clock into a process' address space read-only. Then you don't need a system call, or a fast trap, just a simple function call (or perhaps a millicode stub on the HP) Many things could benefit here, the whole UAREA of a process could be mapped read-only without negative effects, I'd think. Then getpid() isn't a system call, getuid() isn't, etc., etc. Is there a reason why this isn't done? Doug Siebert || dsiebert@isca.uiowa.edu || Defeat Usenet spool grepping! Kibo Turkey Greece Macedonia Perl Watcom Mason Clinton Illuminati Fnord Hastur ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-26 0:57 ` Doug Siebert @ 1994-01-26 8:11 ` Casper H.S. Dik 1994-01-27 4:07 ` Greg Limes 1 sibling, 0 replies; 13+ messages in thread From: Casper H.S. Dik @ 1994-01-26 8:11 UTC (permalink / raw) dsiebert@icaen.uiowa.edu (Doug Siebert) writes: >Could someone explain to me exactly WHY this has to be a system call at all? >It seems to me it would make a GREAT deal of sense to map things like the >hardware clock into a process' address space read-only. Then you don't need >a system call, or a fast trap, just a simple function call (or perhaps a >millicode stub on the HP) Many things could benefit here, the whole UAREA of >a process could be mapped read-only without negative effects, I'd think. Then >getpid() isn't a system call, getuid() isn't, etc., etc. Is there a reason >why this isn't done? Whil for a number of things (getpid(), getppid(), getid()) a memory mapped area in the process space is a solution, nut only because those field hardly ever change. I don't think it is a solution for fast changing things like clocks. Reading the clock (on one processor) while it's being updated by another, may lead to confusing times. And, modern unixes no longer use the tick as granularity of the clock. The hardware clock is used to interpolate the missing microsecond resolution. Reading such a device from userland may be difficult or impossible, and you no longer have ability to hide the details of the clock chip from userland (need a different libc.so for each clock chip you may have, nreaking statically linked programs, or put special hardware detection code in te gettimeofday call). Such things are better left to the kernel. Casper ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-26 0:57 ` Doug Siebert 1994-01-26 8:11 ` Casper H.S. Dik @ 1994-01-27 4:07 ` Greg Limes 1 sibling, 0 replies; 13+ messages in thread From: Greg Limes @ 1994-01-27 4:07 UTC (permalink / raw) barts@cyber.Eng.Sun.COM (Bart Smaalders) writes: >Gettimeoday(2) is implemented as a fast trap since Solaris 2.2. As a result, >this call takes about 2->3 microseconds on a SS10 (slightly more on an SS2). >It returns answers accurate to the resolution of the hardware clock (1 microsecond >on 4[cmd] platforms). In article <1994Jan26.005700.2572@icaen.uiowa.edu>, Doug Siebert <dsiebert@icaen.uiowa.edu> wrote: >It seems to me it would make a GREAT deal of sense to map things like the >hardware clock into a process' address space read-only. > ... > Is there a reason >why this isn't done? Note the "2-3 microseconds". That's a lot better than the cost to get into and back from a system call, last I heard :-) :-) The problem is that the hardware clock doesn't give the complete time; on most suns, you get something indicating the time since the latest timer tick. Of course, if the kernel kept a data page that was full of interesting data (like "what time it was a moment ago") then the library *could* do a gettimeofday without ever passing into system land. But ... try to generalize that for everything Solaris runs on, and things start getting sticky. I'd imagine that HP and DEC have similar issues. for comp.sys.sun.apps folks ... SunOS 4.1.[23] Sun-4M easter egg: I left the 64-bit high resolution timers mapped readable from userland, at 0xFD020000 (you can verify the address by checking for the symbol "_utimers" in /vmunix). BTW, using the above is of course "not supported" and will not work in Solaris 2 ... nor will it work on anything other than a Sun-4M or compatible hardware. -- Greg Limes [limes@netcom.com] Not in any way affiliated with Sun Microsystems ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-25 8:08 ` Bart Smaalders 1994-01-25 18:42 ` Bob Manchek 1994-01-26 0:57 ` Doug Siebert @ 1994-01-29 5:07 ` mark hahn 2 siblings, 0 replies; 13+ messages in thread From: mark hahn @ 1994-01-29 5:07 UTC (permalink / raw) Bart Smaalders (barts@cyber.Eng.Sun.COM) wrote: | On SS10 M51 running the next release of Solaris: | min = .000002, mean = .000003 | On HP 9000/755 running HP-UX A.09.01 C: | min = .000017, mean = .000021 using the appended program, I measured: our hp735 running hpux A.09.01 A min is 9, average is 10.760459. (for scale, getpid takes ~.6 uS here.) out alpha 3400 running osf1 V1.3 111: min is 0, average is 13.289884. (in fact, ignoring preemptions, the delta was either 0, 976 or 977!) on a sun ss10/51, running 4.1.3: min is 12, average is 16.132984. on a sun 4/600 (4x cy 605's) running 4.1.2: min is 27, average is 82.008936. on some kinda r4k MP box from sgi, running irix 5.1.1: min is 12, average is 13.010583. on a gateway 486dx2/66 running Linux 0.99.14w: min is 12, average is 13.389410. regards, mark hahn. #include <stdio.h> #include <sys/time.h> #include <limits.h> #define COUNT 1000000 int main() { unsigned min = UINT_MAX; unsigned sum = 0; unsigned i; static struct timeval tvs[COUNT]; for (i = 0; i < COUNT; i++) { gettimeofday(&tvs[i],0); } for (i = 1; i < COUNT; i++) { unsigned delta = (((tvs[i].tv_sec - tvs[i-1].tv_sec) * 1000000) + (tvs[i].tv_usec - tvs[i-1].tv_usec)); if (delta < min) min = delta; sum += delta; } printf("min is %u, average is %f.\n", min, (float)sum/COUNT); return 0; } -- this space intentionally left non-blank. hahn@neurocog.lrdc.pitt.edu ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) 1994-01-20 20:40 Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) NeoSwami 1994-01-20 21:42 ` Paul Gootherts @ 1994-01-21 16:59 ` Bart Smaalders 1 sibling, 0 replies; 13+ messages in thread From: Bart Smaalders @ 1994-01-21 16:59 UTC (permalink / raw) For SPARC machines: Use gettimeofday. The resolution of the timer will vary with the OS. Before Solaris 2.2, the time value was updated by the clock (100 Hz). Since then, gettimeofday is accurate to 1 microsecond on 4c (ss1->2), 4m(ss10) and 4d (ss[12]000) platforms. - Bart ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~1994-01-29 5:07 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 1994-01-20 20:40 Accessing Real Time Clock in workstations (HPs, Suns, Dec Alphas) NeoSwami 1994-01-20 21:42 ` Paul Gootherts 1994-01-21 12:23 ` Kell S|nnichsen 1994-01-21 15:48 ` john.j.rushford..jr 1994-01-21 19:25 ` Guy Harris 1994-01-24 17:12 ` Benjamin Z. Goldsteen 1994-01-25 8:08 ` Bart Smaalders 1994-01-25 18:42 ` Bob Manchek 1994-01-26 0:57 ` Doug Siebert 1994-01-26 8:11 ` Casper H.S. Dik 1994-01-27 4:07 ` Greg Limes 1994-01-29 5:07 ` mark hahn 1994-01-21 16:59 ` Bart Smaalders
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox