Windows Server上的PTP同步(与Linux相比)-可以保证什么精度 [英] PTP sync on windows server (compared to i.e. Linux) - what precision can be guaranteed

查看:773
本文介绍了Windows Server上的PTP同步(与Linux相比)-可以保证什么精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否每个人都知道在Windows上可以保证 PTP 同步的精确度Server 2008.

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

我知道此线程:什么Windows中的进程的最短保证时间是多少? 讨论了Windows的本地时间,是的,这根本没有任何保证.

I know about this thread: What is the minimum guaranteed time for a process in windows? which discusses windows' native time and yes, this does not give any guarantees at all.

但是关于硬件解决方案(PTP)呢?是否有任何限制会阻止< 1毫秒?我知道取决于时间的进程将争夺CPU时间,但是如果该进程在需要时有CPU时间,还有其他可能吗?

But what when it comes to hardware solutions (PTP)? Are there any limitations preventing a guarantee of < 1ms? I know the processes depending on the time will be competing for CPU time but if the process DOES have CPU time when needed, are there anything else the might come in the way?

我在标题中添加了(与Linux相比)",因为这最初是我关心的问题之一.

推荐答案

可以安排一些措施来获取Windows Server 2008上可靠的处理时间. 其中一些是:

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

  1. 避免在CPU上造成沉重负担.

  1. Avoiding heavy load on the CPU.

安排较小的代码占用内存.

Arrange for small memory footprint of the code.

设置线程优先级高.甚至可能分别高达REALTIME_PRIORITY_CLASSTHREAD_PRIORITY_TIME_CRITICAL.

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

设置

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.

在适当的情况下使用Sleep(0). Sleep(0)是异步服务,它强制调度程序做出反应.通过这种方式,您可以触发调度程序,该调度程序将选择您的进程/线程以立即获得CPU,因为它具有最高的优先级.

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.

确保代码也确实为其他服务提供了时间.最高优先级将导致所有其他线程基本停止. (不会处理任何鼠标事件或其他任何事件)

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)

可能通过mutimedia计时器API来增加系统中断频率.使用 timeGetDevCaps 函数以查询系统允许的最大中断频率,并使用 timeEndPeriod 完成后.

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.

认真遵守这些规则后,可以高度可靠地获得进入10微秒状态的准确时间.但是,上述所有内容的总和导致了一些复杂性.因此,永远不能给予保证.但是即使在RTOS系统上也没有这样的保证.如果编码未正确完成,则无论调用OS的方式如何,事情都不会按照应有的方式工作.可以在此处找到更多注释和指向等效.Net服务的链接.

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.

通过所有这些操作,可以实现时间同步(精确时间协议)长达10微秒.

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.

也要求Linux之后有一些可用的软件包,例如

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.

毫不奇怪,当在可比较的标准硬件上运行时,Windows和Linux的结果非常相似.两者中没有一个能做任何魔术.

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.

这篇关于Windows Server上的PTP同步(与Linux相比)-可以保证什么精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆