Re: Managed directsound problem under heavy CPU load

From: Vasanth Philomin (vasiATnospam.cs.umd.edu)
Date: 05/27/04


Date: Thu, 27 May 2004 15:11:02 -0700

Hi,
As soon as i posted to the group, I tried out the old wave API and had the exact same problem. This kind of showed that it was not the directsound managed API but rather something basic having to do with threading that caused the problem. I then stumbled on Thread.Sleep() and everything worked great after that. Thanks for your comprehensive reply that explains the details clearly.
Vasi
     
     ----- Chris P. [MVP] wrote: -----
     
     Well, I don't know crap about C# but I understand the senario.
     
     Whenever you have badly behaved threads that consume 100% CPU there is going
     to be a problem. I say badly behaved as there is a right way and a wrong
     way to consume 100% CPU in a processing intensive thread. The wrong way is
     to tightly loop and never yield. The correct way is to yield at least once
     every 10-25ms so that other threads on the system can get their time slice.
     You can yield by calling Sleep(), Sleep(0) technically will yield the
     remainder of the time slice to another thread. However depending on the
     frequency of the call you're probably better off calling Sleep() with a
     small value such as Sleep(1) or Sleep(5). Your thread is still going to
     likely consume near 100% CPU in the scheme of things. Also it is correct to
     schedule the thread priorities like you did. It helps but isn't always a
     total solution unless you make the threads play nice with each other. You
     might get away with it if you set the heavy threads to only process on idle,
     that way they should get preempted by everything.
     
     
     



Relevant Pages

  • Re: Managed directsound problem under heavy CPU load
    ... > The code uses the managed directsound api to play back (render) some ... Whenever you have badly behaved threads that consume 100% CPU there is going ... The correct way is to yield at least once ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: [BUG] long freezes on thinkpad t60
    ... kind of setup (and "jiffies" may well be updated on another CPU: ... The whole point of cpu_relaxis about busy-looping, ... I agree - we can get into a loop that calls yield(). ...
    (Linux-Kernel)
  • Re: Where to find statistics for fetched programs?
    ... I got the question how frequently programmes are fetched, ... and then how much CPU they consume. ... This in order to put together kind of a hit parade of big CPU consumers & then tackle their tuning. ... RMF can't help me while Monitor I and Monitor III provide long-term data collection about system workload and resource utilization, while covering all hardware and software components of the system. ...
    (bit.listserv.ibm-main)
  • Where to find statistics for fetched programs?
    ... I got the question how frequently programmes are fetched, ... and then how much CPU they consume. ... This in order to put together kind of a hit parade of big CPU consumers & then tackle their tuning. ... RMF can't help me while Monitor I and Monitor III provide long-term data collection about system workload and resource utilization, while covering all hardware and software components of the system. ...
    (bit.listserv.ibm-main)
  • Re: CPU usage, memory and virtual memory
    ... some applications can consume close to 100% cpu ... usage and freeze up the machine. ... tells me it consumes 99% cpu and a lot of memory and virtual memory ...
    (microsoft.public.vc.mfc)

Loading