[wdmaudiodev] Re: very low latency audio and a C# UI?

  • From: Tim Roberts <timr@xxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Thu, 26 Feb 2009 11:47:38 -0800

Voelkel, Andy wrote:
> Thanks. That helps, just to know it is possible. One of the things I
> don’t know how to do create an “unmanaged threads”. I was under the
> impression that threads themselves aren’t managed or unmanaged, only
> code was.

You're quite right; I spoke too loosely.  What I really meant was
"threads that execute unmanaged code".

> And therefore I don’t know how to arrange it so that the gc knows that
> my low latency thread doesn’t contain unmanaged code and thereform
> doesn’t suspend it”.

As I understand it, the garbage collector doesn't force a thread to be
suspended.  It merely "borrows" a thread at a convenient time, when the
thread has made some managed call that involves memory.  Do you remember
writing Win16 applications?  There were certain API calls that could
cause your application to yield its time slice to another application,
otherwise you never gave up the CPU.  It's the same concept here.  If
you have a thread that never makes any .NET calls, then it will never
enter the garbage collector.

At least, that's my understanding.  Although I have written a fair
amount of C# code, there are still a lot of things about .NET where I am
quite fuzzy.  I do know that DirectShow works very well when driven by a
C# app, and that couldn't work if the threads were suddenly being yanked

Remember, after all, that Windows Media Center is a C# managed
application with a DirectShow core.

> Do you have any book or other reading recommendations that would
> enlighten me on such issues?

I've heard good things about Richter's "CLR via C#", and very good
things about Cwalina's "Framework Design Guidelines: Conventions Idioms,
and Patterns for Reusable .NET Libraries."  I don't have any good
references on mixing managed and unmanaged code, although Google has a
lot of hits for that phrase.

Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.

Other related posts: