none
How to stop operating system tasks while executing. RRS feed

  • Question

  • We have an application that needs to process 1000 images and inspections per minute.  This allows us ~67 ms to complete each task.

    we are able to accomplish this but every so often we see a delay of 50 to 200 ms.

    We believe it is the operating system taking processor time.

    Is there a way to programatically shut down the operating sysem asks during execution?


    Curtis A. Fleischer
    We are forcing Garbage Collection every task, so, we don't believe it is GC that is causing the delay.
    • Edited by Curtf Tuesday, August 30, 2011 11:57 AM additional comments
    Tuesday, August 30, 2011 11:42 AM

Answers

  • You cannot shut down the OS.  Windows is a preemptive (and non-deterministic) OS.  No thread can stall Windows by refusing to yield processor time.  Cooperative OSes (like Win 3.1) died years ago (excluding the embedded market arena).  The best you can do is upgrade your thread priority to real-time but doing that requires admin privileges.  You still don't get any more time then you normally would but Windows would schedule your thread to run more often.  Note that irrelevant of what you do there is always the possibility that your thread will get stalled.  Windows is non-deterministic so no guarantees are every given.

    Michael Taylor - 8/30/2011
    http://msmvps.com/blogs/p3net

     

    Tuesday, August 30, 2011 1:40 PM
    Moderator
  • Messing with the GC when you are not positivelly absolutelly sure what you're doing can be worst than leaving it alone.

    If you shut down the operating system tasks, you shut down the operating system and your application doesn't run. :)

    What .NET runtime are you using? Have you profiled your application to look for memory allocations and garbage collection? Have you collected and analysed performance counters to see what's happening and when?


    Paulo Morgado
    Tuesday, August 30, 2011 12:04 PM

All replies

  • Messing with the GC when you are not positivelly absolutelly sure what you're doing can be worst than leaving it alone.

    If you shut down the operating system tasks, you shut down the operating system and your application doesn't run. :)

    What .NET runtime are you using? Have you profiled your application to look for memory allocations and garbage collection? Have you collected and analysed performance counters to see what's happening and when?


    Paulo Morgado
    Tuesday, August 30, 2011 12:04 PM
  • We have tried letting .NET do the garbage collection.

    Since we are processing several 2500k buffers each task the application can run the memory usage to over 2Gig, this locks up the machine.

    And when GC does kick in the delay is tremendous.


    Curtis A. Fleischer
    Tuesday, August 30, 2011 12:45 PM
  • What .NET runtime are you using? 1.1? 2.0? 4.0?

    What is the type of your application? Web? Windows Service? Console?


    Paulo Morgado
    Tuesday, August 30, 2011 12:54 PM
  • WE are using 4.0  WPF C#
    Curtis A. Fleischer
    Tuesday, August 30, 2011 12:55 PM
  • You cannot shut down the OS.  Windows is a preemptive (and non-deterministic) OS.  No thread can stall Windows by refusing to yield processor time.  Cooperative OSes (like Win 3.1) died years ago (excluding the embedded market arena).  The best you can do is upgrade your thread priority to real-time but doing that requires admin privileges.  You still don't get any more time then you normally would but Windows would schedule your thread to run more often.  Note that irrelevant of what you do there is always the possibility that your thread will get stalled.  Windows is non-deterministic so no guarantees are every given.

    Michael Taylor - 8/30/2011
    http://msmvps.com/blogs/p3net

     

    Tuesday, August 30, 2011 1:40 PM
    Moderator
  • Well, Curtis, you can try to configure the GC as server (like ASP.NET).

    Maybe thes links can help you:

    Another workaround is, if you use lots of objects of the same type, you might consider creating your own pool of objects instead of allocating/releasing new ones for every processing operation.


    Paulo Morgado
    Tuesday, August 30, 2011 8:18 PM
  • You say you believe the OS is taking up resources, what evidence do you have for that?

    Processing 1000 images per second (assuming ~1 MB per image) sounds like something better done by the graphics card. If you're truly saturating the processor, have virtual false cache sharing, and threads from your process aren't context swapping eachother out, the next step is to use the DirectX DirectCompute api to offload work to the GPU (assuming the work your doing against the images is embarassingly parallel).

    Tuesday, August 30, 2011 8:35 PM