pcp
[Top] [All Lists]

Re: [pcp] pmie and system clock changes

To: Martin Hicks <mort@xxxxxxx>
Subject: Re: [pcp] pmie and system clock changes
From: Greg Banks <gnb@xxxxxxxxxxx>
Date: Thu, 6 May 2010 12:30:16 +1000
Cc: "pcp@xxxxxxxxxxx" <pcp@xxxxxxxxxxx>
In-reply-to: <20100505201154.GX25390@xxxxxxxxxxxxxxxxxxxxxxxxx>
References: <20100505201154.GX25390@xxxxxxxxxxxxxxxxxxxxxxxxx>
User-agent: Thunderbird 2.0.0.23 (X11/20090817)
Martin Hicks wrote:

1272757518.386530 gettimeofday({1272757518, 386539}, NULL) = 0
1272757518.386562 nanosleep({18446744073709013957, 18446744073070619627}, 
0x7fff22cbaf90) = -1 EINVAL (Invalid argument)



I believe what has happened is:

- Machine's clock is set far in the past
- pmie starts and notes the epoch for polling the pmcd.  It then polls at even
  intervals where:  next poll == epoch + poll_count * poll_delay
- ntp starts, and warps time forward by a couple years.
- pmie spins, failing nanosleep() because the "next poll" is still a long way in
  the past and advancing by poll_delay at each subsequent call until it gets to
  the present time.


Attached is my first crack at fixing it, but I don't love it because:


The right way to fix this is to use the POSIX API clock_gettime(CLOCKID_MONOTONIC) instead of gettimeofday() to calculate time intervals for nanosleep(). That is widely available on modern OSes, although you should check for it at configure time.

--
Greg.

<Prev in Thread] Current Thread [Next in Thread>