PTP sync on windows server (compared to i.e. Linux) - what precision can be guaranteed

前端 未结 1 501

I would like to know if everyone knows how precise PTP synchronization can be guaranteed on Windows Server 2008.

I know about this thread: What is the minimum guaranteed

1条回答
  •  梦毁少年i
    2021-02-06 18:15

    A few things can be arranged to obtain reliable process times on Windows Server 2008. Some of them are:

    1. Avoiding heavy load on the CPU.

    2. Arrange for small memory footprint of the code.

    3. Set the process priority class and the thread priority high. Possibly even as high as REALTIME_PRIORITY_CLASS and THREAD_PRIORITY_TIME_CRITICAL respectively.

    4. Set the thread affinity mask to avoid that the time critical part runs on Core 0. Core 0 is dedicated to some of the system services. Using a different code avoids dependencies.

    5. Use of Sleep(0) when appropriate. Sleep(0) is an asynchronous service and forces the scheduler to react. This way you can trigger the scheduler which will choose your process/thread to get CPU immedeately since it has utmost priority.

    6. Ensure that the code does give time to other services too. Utmost priority will cause all other threads to basically stop. (no mouse events or whatsoever will be processed)

    7. Possibly increase the systems interrupt frequency by means of the mutimedia timer API. Use the timeGetDevCaps function to query the maximum allowed interrupt frequency of your system and use timeBeginPeriod with wPeriodMin returned by timeBeginPeriod in the TIMECAPS structure. This will force your system to run at its maximum interrupt frequency. Don't forget to release the multimedia timer resource by a call to timeEndPeriod when you are done.

    When these rules are carfully followed, accurate timing into the 10 microsecond regime is obtainable with ver high reliability. However the sum of all the above results in some complexity. Therefore a guarantee can never be given. But even on RTOS systems there is no such guarantee. When coding is not done properly things don't work the way they are supposed to do, no matter what/how the OS is called. Some more notes and links to the equivalent .Net services can be found here.

    Taking all this enables the implementation of time synchronization (Precision Time Protocol) down to a few 10 microseconds.

    Precision Time Protocol developers faq can be found here.

    Edit after Linux was askted for too: There are some packages available, for example this one. Typical accuracies reported here are in the 10 to 100 microsecond range too.

    Not surprisingly the results are very similar for Windows and Linux when running on comparable standard hardware. Non of the two can do anything magic.

    0 讨论(0)
提交回复
热议问题