[ntp:hackers] Using Posix API's to simplify do_resolve_internal()

Philip Prindeville philipp_subx at redfish-solutions.com
Fri Jun 7 16:35:51 UTC 2013


On Jun 7, 2013, at 6:54 AM, Martin Burnicki <martin.burnicki at meinberg.de> wrote:

> Terje Mathisen wrote:
>> Philip Prindeville wrote:
>>> 
>>> On Jun 6, 2013, at 9:42 PM, Terje Mathisen <terje at tmsw.no> wrote:
>>>> I've written a multi-threaded version of ntpd for linux, this
>>>> compiled as-is on both 32 and 64-bit FreeBSD as well, but required
>>>> custom handling on Win*.
>>>> 
>>> 
>>> Could you share that code?  It would be handy in embedded Linux, QNX,
>>> VxWorks, etc. and similar environments.
>> 
>> Sorry, I can't just yet, it was written for a third party.
> 
> Maybe there can be a discussion to see if it's possible to commit the code.
> 
>> OTOH I can share the learnings, the main one being that ntpd really
>> doesn't need to be multi-threaded unless you want to have a dedicated
>> ntp server which handles wire-speed Gbit/s requests, i.e. many million
>> clients.
> 
> This is probably true for the code which handles network requests.
> 
>> It will almost certainly NOT be a win for embedded!
> 
> For things like asynchronous DNS resolving etc. it might be more lightweight to a pthreads with the associated locking mechanisms instead of a fork and a pipe.


And that was the point of my request. There's really no reason for DNS resolving to happen in a separate address space, and address spaces are expensive in embedded systems because of the MMU PTE invalidations and reloading, the cache flush, etc.


> 
> I think this will require a bunch of work, though, and unfortunately there are actually not many people who can spend significant time on the NTP  project.
> 
> A basic question would be if support for systems which don't have pthreads could be dropped, or if this had to be implemented using some conditional code, i.e. #ifdef HAVE_PTHREAD or similar.
> 
> Martin

I think all systems implement threads at this point. The question is whether they are POSIX threads or not.

Under Windows, for instance, POSIX threads are more trouble than they are worth because they aren't as POSIX-y as they should be, and the native thread support is more solid.

-Philip




More information about the hackers mailing list