views:

23

answers:

2

I want to try Multimedia Class Scheduler Service http://msdn.microsoft.com/en-us/library/ms684247(v=VS.85).aspx

I hope it can reduce latency by scheduling my threads better.

How can it be done in C# ?

Note: my app is nothing to do with multimedia I just need features of MMCSS.

+1  A: 

I'm not sure what the point of using the MMCSS would be in a managed application. After all, the point of the MMCSS is to adjust the scheduling priority of the process to avoid stalls during multimedia stream processing - we're talking nanosecond level scheduling. But with a managed language where a garbage collection can happen at any time and potentially take tens or even hundreds of milliseconds, then I'm not sure what benefit the MMCSS would provide that wouldn't be totally wiped out by garbage collection.

With that in mind, I wouldn't expect to see a managed interface to the MMCSS any time soon. You can certainly access it via P/Invoke, but I wouldn't expect miracles from it :)

Dean Harding
I am just curious. every question I asked in SO, the answers start with - you cant, you dont, you shouldnt, you dont need it.... why?..anyway. could you please give me an idea what do I need to call to use MMCSS? Is it like call to "start" in the beginning and "stop" in the end? or is it more complext? what those methods could be?
Bobb
+1  A: 

Each thread that is performing work related to a particular task calls the AvSetMmMaxThreadCharacteristics or AvSetMmThreadCharacteristics function to inform MMCSS that it is working on that task.

It would seem all you need is to P/Invoke one or other of those API calls.

However, I suspect all that will be in vain when the garbage collector steps in and messes things up.

Have you done any profiling of the app to see what's going on under the covers? If you app is truly that latency sensitive then C# is probably the wrong choice of language to be honest.

Paolo
YES I HAVE :) But thank you for the answer.
Bobb
I know this is wrong choice. But this is only choice and nothing I can do about it.. What I CAN do is to ensure the latency is minimized... and what makes you think there is GC involved anyway?
Bobb
@Bobb - It's C#, you can't avoid the garbage collector!
Paolo
oh really :) wonna bet money on it?
Bobb
I'm intrigued as to how you think you can avoid GC in a managed language. You can minimise it sure, but you can't avoid it altogether.
Paolo