[LinuxPPS] select() on a PPS FD/handle

Damien Dusha d.dusha at gmail.com
Wed May 1 02:23:34 CEST 2013


Dear all,

I have an application that waits on several handles and hence being able to
select on a pps handle (or, as in this instance, the raw file descriptor)
is desirable.  However, select() appears to return immediately, reporting
that the FD has data.  For example, the strace -p output is:

select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in
[23], left {0, 99977})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 582135}, NULL) = 0
select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in
[23], left {0, 99986})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 582758}, NULL) = 0
select(32, [9 23 24 25 2[   90.878840] pps pps0: echo assert
[   90.882760] pps pps0: echo  clear
6 27 29 30 31], [], NULL, {0, 100000}) = 1 (in [23], left {0, 99987})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 583401}, NULL) = 0
select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in
[23], left {0, 99991})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 584043}, NULL) = 0
select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in
[23], left {0, 99990})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 584623}, NULL) = 0
select(32, [9 23 24 25 26 27 29 30 31], [], NULL, {0, 100000}) = 1 (in
[23], left {0, 99990})
ioctl(23, PPS_FETCH, 0xbeeee5c8)        = 0
gettimeofday({1367365708, 585176}, NULL) = 0

(The gettimeofday calls can safely be ignored; they are for my application
to calculate latency)

As can be seen, the select returns after 100us or so, even through the
timeout is 100ms, reporting that the [23] (which, in this instance, is the
PPS FD) is waiting to be read.    The API call that follows returns
successfully.

The API call is as follows:

    // According to RFC2783, a timeout of zero will return immediately
    struct timespec zero;
    zero.tv_sec = 0;
    zero.tv_nsec = 0;

    pps_info_t info;
    int return_value = time_pps_fetch(m_handle, PPS_TSFMT_TSPEC, &info,
&zero);

The PPS handle and the raw FD should be the same value (from <timepps.h>):

    /* ... then since in LinuxPPS there are no differences between a
     * "PPS source" and a "PPS handle", we simply return the same value.
     */
    *handle = source;

The PPS client driver is the GPIO client, modified to use the devicetree
[1], should be declared PPS_CANWAIT.

Is this the expected behaviour from select()?  If so, what work needs to be
done in order for the driver to be select()-able?

  --- Damien

[1] http://www.linuxpps.org/pipermail/discussions/2013-April/004416.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.linuxpps.org/pipermail/discussions/attachments/20130501/9bd63aa5/attachment-0002.html>


More information about the discussions mailing list