Re: Counting the clock cycles

2002-07-18 Thread M. Warner Losh

In message: [EMAIL PROTECTED]
Poul-Henning Kamp [EMAIL PROTECTED] writes:
: Unless we want to deal properly with leapseconds and implement TAI,
: we have no choice in that matter.

Well, djm has libraries that keeps the system time in UTC +
leapseconds and causes the right time to be displayed by tweaks to the
timezone files

Warner

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-18 Thread Terry Lambert

Andrei Cojocaru wrote:
 I am already synchronizing using xntp, that's not the problem. The problem is by 
some weird way the clock got out of sync by about 1hr during daylight switch on one 
of the computers I run, and I need a reliable way to get passage of time (I don't 
need date/time, just the passage of it) for different internal operations in the 
program.

Looking for another clock already living there somewhere in the same
PC hardware isn't going to fix it.

You need to disable CMOS daylight savings time swithing in the BIOS,
so that it doesn't jump the reported clock value on you.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-18 Thread Andrei Cojocaru

Does FreeBSD do that or do I have to look for an option in the BIOS?

Andrei Cojocaru
[EMAIL PROTECTED]
- Original Message -
From: Terry Lambert [EMAIL PROTECTED]
To: Andrei Cojocaru [EMAIL PROTECTED]
Cc: Darren Pilgrim [EMAIL PROTECTED]; Cy Schubert - CITS Open
Systems Group [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, July 18, 2002 1:18 AM
Subject: Re: Counting the clock cycles


 Andrei Cojocaru wrote:
  I am already synchronizing using xntp, that's not the problem. The
problem is by some weird way the clock got out of sync by about 1hr during
daylight switch on one of the computers I run, and I need a reliable way to
get passage of time (I don't need date/time, just the passage of it) for
different internal operations in the program.

 Looking for another clock already living there somewhere in the same
 PC hardware isn't going to fix it.

 You need to disable CMOS daylight savings time swithing in the BIOS,
 so that it doesn't jump the reported clock value on you.

 -- Terry



To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-18 Thread Terry Lambert

Andrei Cojocaru wrote:
  Looking for another clock already living there somewhere in the same
  PC hardware isn't going to fix it.
 
  You need to disable CMOS daylight savings time swithing in the BIOS,
  so that it doesn't jump the reported clock value on you.
 
 Does FreeBSD do that or do I have to look for an option in the BIOS?

You need to look for an option in BIOS.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message




Counting the clock cycles

2002-07-17 Thread Andrei Cojocaru

I was asking around in #freebsdhelp on EFNet what the equivalent of
GetTickCount() in the Win32 API is in FreeBSD.

I need a way to properly determine passage of time that is not affected if I
change the system clock for example. The only way I'm aware that you can do
that is by counting the number of clock cycles since system startup. What
function does that in FreeBSD? I'd also like a Linux way if possible. (that
is a way that will work across all UNIX clones). Thanks and please include
my email in the reply directly since I'm not signed up to this mailing list.
Thanks once again.

Andrei Cojocaru
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Terry Lambert

Andrei Cojocaru wrote:
 I was asking around in #freebsdhelp on EFNet what the equivalent of
 GetTickCount() in the Win32 API is in FreeBSD.
 
 I need a way to properly determine passage of time that is not affected if I
 change the system clock for example. The only way I'm aware that you can do
 that is by counting the number of clock cycles since system startup. What
 function does that in FreeBSD? I'd also like a Linux way if possible. (that
 is a way that will work across all UNIX clones). Thanks and please include
 my email in the reply directly since I'm not signed up to this mailing list.

Use the Pentium Cycle Counter.

Note that power management is going to make it inaccurate as a
time base.

Give up on the idea that you will have a wall time that is more
accurate than the CMOS clock; after you've embraced that, you
can learn to stop worrying and love Intel.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Alfred Perlstein

* Andrei Cojocaru [EMAIL PROTECTED] [020717 12:02] wrote:
 I was asking around in #freebsdhelp on EFNet what the equivalent of
 GetTickCount() in the Win32 API is in FreeBSD.
 
 I need a way to properly determine passage of time that is not affected if I
 change the system clock for example. The only way I'm aware that you can do
 that is by counting the number of clock cycles since system startup. What
 function does that in FreeBSD? I'd also like a Linux way if possible. (that
 is a way that will work across all UNIX clones). Thanks and please include
 my email in the reply directly since I'm not signed up to this mailing list.
 Thanks once again.

I don't see a platform independant way of doing this, sorry.

Have a look at the source for w(1).

http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/w/w.c

Look at the function pr_header(), it uses SYSCTL to grab system
uptime.

-- 
-Alfred Perlstein [[EMAIL PROTECTED]]
'Instead of asking why a piece of software is using 1970s technology,
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Deepankar Das

rdtsc() will give you cycle counts since system boot. It reads a Pentium
internal register which is incremented at every CPU internal clock cycle.

Deepankar

Andrei Cojocaru wrote:

 I was asking around in #freebsdhelp on EFNet what the equivalent of
 GetTickCount() in the Win32 API is in FreeBSD.
 
 I need a way to properly determine passage of time that is not affected if I
 change the system clock for example. The only way I'm aware that you can do
 that is by counting the number of clock cycles since system startup. What
 function does that in FreeBSD? I'd also like a Linux way if possible. (that
 is a way that will work across all UNIX clones). Thanks and please include
 my email in the reply directly since I'm not signed up to this mailing list.
 Thanks once again.
 
 Andrei Cojocaru
 [EMAIL PROTECTED]
 
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with unsubscribe freebsd-hackers in the body of the message
 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Cy Schubert - CITS Open Systems Group

In message 00d501c22dc4$57d08b00$0200a8c0@twothousand, Andrei 
Cojocaru writ
es:
 I was asking around in #freebsdhelp on EFNet what the equivalent of
 GetTickCount() in the Win32 API is in FreeBSD.
 
 I need a way to properly determine passage of time that is not affected if I
 change the system clock for example. The only way I'm aware that you can do
 that is by counting the number of clock cycles since system startup. What
 function does that in FreeBSD? I'd also like a Linux way if possible. (that
 is a way that will work across all UNIX clones). Thanks and please include
 my email in the reply directly since I'm not signed up to this mailing list.
 Thanks once again.

How about time(3)?


--
Cheers,  Phone:  250-387-8437
Cy SchubertFax:  250-387-5766
Team Leader, Sun/Alpha Team  Email:  [EMAIL PROTECTED]
Open Systems Group, CITS
Ministry of Management Services
Province of BC
FreeBSD UNIX:  [EMAIL PROTECTED]




To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Andrei Cojocaru

doesn't fit my criteria since it changes, bah I'll just use gettimeofday since it's a 
portable API and hope the computers I run it on don't change their blocks by too 
much...
- Original Message - 
From: Cy Schubert - CITS Open Systems Group [EMAIL PROTECTED]
To: Andrei Cojocaru [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, July 17, 2002 13:43
Subject: Re: Counting the clock cycles 


 In message 00d501c22dc4$57d08b00$0200a8c0@twothousand, Andrei 
 Cojocaru writ
 es:
  I was asking around in #freebsdhelp on EFNet what the equivalent of
  GetTickCount() in the Win32 API is in FreeBSD.
  
  I need a way to properly determine passage of time that is not affected if I
  change the system clock for example. The only way I'm aware that you can do
  that is by counting the number of clock cycles since system startup. What
  function does that in FreeBSD? I'd also like a Linux way if possible. (that
  is a way that will work across all UNIX clones). Thanks and please include
  my email in the reply directly since I'm not signed up to this mailing list.
  Thanks once again.
 
 How about time(3)?
 
 
 --
 Cheers,  Phone:  250-387-8437
 Cy SchubertFax:  250-387-5766
 Team Leader, Sun/Alpha Team  Email:  [EMAIL PROTECTED]
 Open Systems Group, CITS
 Ministry of Management Services
 Province of BC
 FreeBSD UNIX:  [EMAIL PROTECTED]
 
 
 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Darren Pilgrim

Andrei Cojocaru wrote:
 
 doesn't fit my criteria since it changes, bah I'll just use
 gettimeofday since it's a portable API and hope the computers I run
 it on don't change their blocks by too much...

If you're really worried about it, get a GPS device that can provide
you with a PPS signal for use with ntpd.  Then I'd say you could safely
rely on the computer's clock being accurate.

 From: Cy Schubert - CITS Open Systems Group [EMAIL PROTECTED]
  In message 00d501c22dc4$57d08b00$0200a8c0@twothousand, Andrei
  Cojocaru writes:
   I was asking around in #freebsdhelp on EFNet what the equivalent of
   GetTickCount() in the Win32 API is in FreeBSD.
  
   I need a way to properly determine passage of time that is not affected if I
   change the system clock for example. The only way I'm aware that you can do
   that is by counting the number of clock cycles since system startup. What
   function does that in FreeBSD? I'd also like a Linux way if possible. (that
   is a way that will work across all UNIX clones). Thanks and please include
   my email in the reply directly since I'm not signed up to this mailing list.
   Thanks once again.
 
  How about time(3)?

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Andrei Cojocaru

I am already synchronizing using xntp, that's not the problem. The problem is by some 
weird way the clock got out of sync by about 1hr during daylight switch on one of the 
computers I run, and I need a reliable way to get passage of time (I don't need 
date/time, just the passage of it) for different internal operations in the program.
- Original Message - 
From: Darren Pilgrim [EMAIL PROTECTED]
To: Andrei Cojocaru [EMAIL PROTECTED]
Cc: Cy Schubert - CITS Open Systems Group [EMAIL PROTECTED]; 
[EMAIL PROTECTED]
Sent: Wednesday, July 17, 2002 14:25
Subject: Re: Counting the clock cycles


 Andrei Cojocaru wrote:
  
  doesn't fit my criteria since it changes, bah I'll just use
  gettimeofday since it's a portable API and hope the computers I run
  it on don't change their blocks by too much...
 
 If you're really worried about it, get a GPS device that can provide
 you with a PPS signal for use with ntpd.  Then I'd say you could safely
 rely on the computer's clock being accurate.
 
  From: Cy Schubert - CITS Open Systems Group [EMAIL PROTECTED]
   In message 00d501c22dc4$57d08b00$0200a8c0@twothousand, Andrei
   Cojocaru writes:
I was asking around in #freebsdhelp on EFNet what the equivalent of
GetTickCount() in the Win32 API is in FreeBSD.
   
I need a way to properly determine passage of time that is not affected if I
change the system clock for example. The only way I'm aware that you can do
that is by counting the number of clock cycles since system startup. What
function does that in FreeBSD? I'd also like a Linux way if possible. (that
is a way that will work across all UNIX clones). Thanks and please include
my email in the reply directly since I'm not signed up to this mailing list.
Thanks once again.
  
   How about time(3)?


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Julian Elischer

depending on the acuracy needed use the uptime..


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Poul-Henning Kamp

In message 005f01c22dd1$7be7d180$0300a8c0@fivehundred, Andrei Cojocaru writ
es:
I am already synchronizing using xntp, that's not the problem. The
problem is by some weird way the clock got out of sync by about 1hr
during daylight switch on one of the computers I run, and I need a
reliable way to get passage of time (I don't need date/time, just
the passage of it) for different internal operations in the program.

Use UTC time, it has no daylight savings problems.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Andrei Cojocaru

yes but how do you get the uptime?
- Original Message - 
From: Julian Elischer [EMAIL PROTECTED]
To: Darren Pilgrim [EMAIL PROTECTED]
Cc: Andrei Cojocaru [EMAIL PROTECTED]; Cy Schubert - CITS Open 
Systems Group [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, July 17, 2002 14:50
Subject: Re: Counting the clock cycles


 depending on the acuracy needed use the uptime..
 


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread kkonaka

 I need a way to properly determine passage of time
 that is not affected if I change the system clock
 for example.

how about using setitimer(2) - ITIMER_REAL?  

since it appears(?) on almost all unix(-like)
platforms this expires based only on callout (or
jiffies) ticks countdown, and settimeofday(2) never
seems to bother adjusting callout queues.

kenji

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread M. Warner Losh

In message: [EMAIL PROTECTED]
Darren Pilgrim [EMAIL PROTECTED] writes:
: If you're really worried about it, get a GPS device that can provide
: you with a PPS signal for use with ntpd.  Then I'd say you could safely
: rely on the computer's clock being accurate.

If you are lucky enough to find accuracy in the 10s of us close enough.

Warner

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread M. Warner Losh

In message: [EMAIL PROTECTED]
Poul-Henning Kamp [EMAIL PROTECTED] writes:
: In message 005f01c22dd1$7be7d180$0300a8c0@fivehundred, Andrei Cojocaru writ
: es:
: I am already synchronizing using xntp, that's not the problem. The
: problem is by some weird way the clock got out of sync by about 1hr
: during daylight switch on one of the computers I run, and I need a
: reliable way to get passage of time (I don't need date/time, just
: the passage of it) for different internal operations in the program.
: 
: Use UTC time, it has no daylight savings problems.

Just stupid leap-seconds :-(

Warner

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Darren Pilgrim

M. Warner Losh wrote:
 
 In message: [EMAIL PROTECTED]
 Darren Pilgrim [EMAIL PROTECTED] writes:
 : If you're really worried about it, get a GPS device that can provide
 : you with a PPS signal for use with ntpd.  Then I'd say you could safely
 : rely on the computer's clock being accurate.
 
 If you are lucky enough to find accuracy in the 10s of us close enough.

I don't quite understand what you're saying here.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread M. Warner Losh

In message: [EMAIL PROTECTED]
Darren Pilgrim [EMAIL PROTECTED] writes:
: M. Warner Losh wrote:
:  
:  In message: [EMAIL PROTECTED]
:  Darren Pilgrim [EMAIL PROTECTED] writes:
:  : If you're really worried about it, get a GPS device that can provide
:  : you with a PPS signal for use with ntpd.  Then I'd say you could safely
:  : rely on the computer's clock being accurate.
:  
:  If you are lucky enough to find accuracy in the 10s of us close enough.
: 
: I don't quite understand what you're saying here.

I'm saying that ntp steers the system clock only +- 40-70us (eg a few
10's of us) in the best client situation on a LAN.  Reference clocks
can get the system time deviation down to a few microseconds (on the
order of 2-5us).  phk claims to have gotten better with custom clock
hardware...  of course these numbers are from FreeBSD 4.3 and the ntp
nano-kernel in the kernel has gotten a little better since then.

Warner

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message



Re: Counting the clock cycles

2002-07-17 Thread Poul-Henning Kamp

In message [EMAIL PROTECTED], M. Warner Losh writes:
In message: [EMAIL PROTECTED]
Poul-Henning Kamp [EMAIL PROTECTED] writes:
: In message 005f01c22dd1$7be7d180$0300a8c0@fivehundred, Andrei Cojocaru writ
: es:
: I am already synchronizing using xntp, that's not the problem. The
: problem is by some weird way the clock got out of sync by about 1hr
: during daylight switch on one of the computers I run, and I need a
: reliable way to get passage of time (I don't need date/time, just
: the passage of it) for different internal operations in the program.
: 
: Use UTC time, it has no daylight savings problems.

Just stupid leap-seconds :-(

Well, I have already sent comments to the latest IERS questionaire
telling them how ugly we think those are.

Unless we want to deal properly with leapseconds and implement TAI,
we have no choice in that matter.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message