使用多媒体计时器 [英] Using Multimedia Timers

查看:117
本文介绍了使用多媒体计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个同事有以下问题:

A co-worker of mine has the following question:


我尝试使用TS_SetPeriodicEvent()生成周期性的10ms事件,然后使用该事件每10ms生成数百个UDP数据包.


I am attempting to use TS_SetPeriodicEvent() to generate periodic 10ms events, which I then use to generate hundreds of UDP packets every 10ms.

我遇到的问题是,默认情况下,Windows计时器的分辨率要比10ms大得多,并且不使用多媒体计时器就可以获得的最佳分辨率为15.15 ms.使用多媒体计时器,我可以获得所需的分辨率,但是CPU 使用非常精细的分辨率时,利用率会从屋顶射出.

The problem I'm running into is that, by default, Windows timers have a much coarser resolution than 10ms and the best resolution I can get without using multimedia timers is 15.15 ms. With multimedia timers I can get the desired resolution, but the CPU utilization shoots through the roof when using very fine resolutions.

我的应用程序可以使用数百个线程来执行语音信号处理;因此我无法使用多媒体计时器,因为我在高负载下用尽了CPU时间.在负载少且只有几个线程的情况下,CPU利用率可以忽略不计.非多媒体 即使在具有数百个线程的非常高的负载下,计时器也不会出现CPU使用率问题.

My application can use hundreds of threads to perform voice signal processing; hence I cannot use the multimedia timer since I run out of CPU time at high loads. At small loads, with only a few threads, the CPU utilization is negligible. The non-multimedia timer does not have the CPU utilization problem even at very high loads with several hundred threads.

在多媒体定时器不带来高CPU使用率的情况下,如何在用户空间中获得所需的定时器分辨率?

What I can do (in user space) to get the desired timer resolution without the high CPU utilization that comes with using the multimedia timers?

推荐答案

您是否要在数百个线程中的每个线程中使用多媒体计时器?如果是这种情况,您应该通过重新设计来更改该设计,该设计仅对整个应用程序使用一个多媒体计时器,然后使用消息向线程发出信号 或事件.
Are you trying to use a multimedia timer in each of the hundreds of threads?  If that is the case you should change that design with a redesign that uses just one multimedia timer for the entire application, then signals the threads using messages or events.


这篇关于使用多媒体计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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