thread priority

This is a discussion on thread priority within the C# Programming forums, part of the General Programming Boards category; Hello everyone, I am confused about the statement from the book Threading in C# about thread priority, http://www.albahari.com/threading/ the confusing ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    thread priority

    Hello everyone,


    I am confused about the statement from the book Threading in C# about thread priority,

    http://www.albahari.com/threading/

    the confusing statement is, "The ideal solution is to have the real-time work and user interface in separate processes". Why the solution works and ideal?

    The whole paragraph is,

    --------------------
    If the real-time application has a user interface, it can be undesirable to elevate the process priority because screen updates will be given excessive CPU time Ė slowing the entire computer, particularly if the UI is complex. (Although at the time of writing, the Internet telephony program Skype gets away with doing just this, perhaps because its UI is fairly simple). Lowering the main threadís priority Ė in conjunction with raising the processís priority Ė ensures the real-time thread doesnít get preempted by screen redraws, but doesnít prevent the computer from slowing, because the operating system will still allocate excessive CPU to the process as a whole. The ideal solution is to have the real-time work and user interface in separate processes (with different priorities), communicating via Remoting or shared memory. Shared memory requires P/Invoking
    the Win32 API (web-search CreateFileMapping and MapViewOfFile).
    --------------------


    thanks in advance,
    George

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    it just means that for RT task you want to set process and thread priority to maximum

    if you have a UI thread in the same application - you can lower the thread priority, but process priority will still be high, giving unneded CPU cycles to the UI thread

    So best solution will be extract UI to another process that can have independent process and thread priorities so no additional CPU cycles will be wasted on UI tasks
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks vart,


    You know so many things -- C++ and C#. Question answered. Cool!

    Quote Originally Posted by vart View Post
    it just means that for RT task you want to set process and thread priority to maximum

    if you have a UI thread in the same application - you can lower the thread priority, but process priority will still be high, giving unneded CPU cycles to the UI thread

    So best solution will be extract UI to another process that can have independent process and thread priorities so no additional CPU cycles will be wasted on UI tasks

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. crazy pipe/fork
    By fortune2k in forum C Programming
    Replies: 8
    Last Post: 03-13-2009, 11:28 AM
  2. Terminating secondary thread from another thread
    By wssoh85 in forum C++ Programming
    Replies: 13
    Last Post: 12-19-2008, 04:14 AM
  3. Thread Prog in C language (seg fault)
    By kumars in forum C Programming
    Replies: 22
    Last Post: 10-09-2008, 01:17 PM
  4. pointer to main thread from worker thread?
    By draegon in forum C++ Programming
    Replies: 2
    Last Post: 10-27-2005, 06:35 AM
  5. Critical Sections, destroying
    By Hunter2 in forum Windows Programming
    Replies: 4
    Last Post: 09-02-2003, 10:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21