[LinuxPPS] More on problem with the PPS Device.

Cirilo Bernardo cirilo.bernardo at gmail.com
Mon Jun 30 08:56:09 CEST 2008


On Mon, Jun 30, 2008 at 4:03 AM,  <clemens at dwf.com> wrote:
>
> There is something strange about this list.
> I posted the referenced article to this list yesterday at 16:10 and I received
> a copy from the list at 16:11. Fine
> Rodolfo replied to the message at 03:21 this morning, but his response,
> which was directed to both me and the list has yet to appear on the list.
> That's 18+ hours.
>
> So, I am replying to something that no-one else has seen.
>

I think I'm seeing the replies; do you have an overzealous spam
filter?  I'll check again; it is possible that I was on the 'CC' list.

> ---
>
> In any case, I accept Rodolfo's explanation of what is going on in
> the kernel and userland.
>
> I have to question if my doing a
>
>    system("mknod /dev/pps1 c 254 1");
>
> just qualifies a an additional delay (like my sleep(5) ) or if more is
> going on there.
>

The 'system' call does not return until the command invoked returns;
by the time 'mknod' returns, the device node is created and since the
IOCTL to set the N_PPS ldisc had already been called, the device node
is good to use.

The 'udev' problem as Rodolfo  explained, is that an event is posted
but it takes some time before udev creates the node.  This may be due
to the fact that the scheduler has not yet scheduled udev so udev has
had no chance to create the node; can you please test again with udev
and a single 'sched_yield' after the IOCTL?

> But more important, is there some way to work around needing a
> userland delay to allow udev to do its work.
>
> It would be nice to have something that actually waited for the
> device to be created, but mabe that's not possible.
>

Yes, it is possible to check if the device exits - perform an fstat on
the filename (pps0, pps1 - whatever) and do a usleep() or
sched_yield() in a loop until the device exists.  Of course this makes
the NTP code look ugly and is what the NTP developers like to call a
"Linuxism".  I think the fstat + usleep is portable but no one else
seems to need it.  This could be largely due to the fact that most
*NIX systems do not create device nodes dynamically; they still use
the ancient system where you create all the device nodes which you
think can possibly exist (and really clutter up the /dev directory).

> [[ and yes one could do a while and a usleep of a few tens of ms,
>    waiting for the device to appear,- but frankly, just waiting
>    for 5 seconds seems cleaner than that... ]]
>
> Any thoughts??

Even waiting for 5 seconds seems to be an ugly kludge; it's better to
call 'mknod' instead, but I'm betting the NTP people grumble a lot.

- Cirilo



More information about the LinuxPPS mailing list