CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Kofan View Post
    The number of threads equal to the number of processor-cores. By setting a high priority threads - all cores busy my application and CPU load at 100%. If the thread priorities are normal CPU load only 50-60% because in fact some kernel idle, and the program runs very slowly.
    This doesn’t make much sense.
    You are saying that your threads (with normal priorities) are NOT utilizing CPU at 100%? What are they waiting for if no one else is using that CPU?
    It sounds like you don’t have enough threads running simultaneously.
    For example, if I create a busy thread doing something like
    Code:
    while(true)
        i++;
    and if some processor core is available, it will use 100% of that core whatever it’s priority is – right?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  2. #17
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Kofan View Post
    Lindley, сan You explain more about the environment variables, because I do not use them anywhere in the code explicitly. Can they be used by the Intel-compiler implicitly?
    Presumably the issue isn't with the compiler, or else you wouldn't be seeing different behavior during two different runs with the same executable.

    It's possible that one of the libraries you are using uses environment variables in some way. Check their docs.

  3. #18
    Join Date
    Jan 2012
    Posts
    7

    Re: The strange performance of Visual C++ application

    The interface-thread is synchronized with the work-threads using "join" method of std::thread (tbb::thread) class. Shared data synchronized with tbb::mutex.

    VladimirF, if the thread has the highest priority, it wil get the next quantum of CPU time. Otherwise, a thread can wait long enough, because the processor will work with other threads that have a higher priority (it can be the OS-threads or threads of other applications).

  4. #19
    Join Date
    Apr 1999
    Posts
    27,449

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Kofan View Post
    within Visual studio in debug mode (by pressing F5) the project runs much faster than when it started the outside of Visual studio (starting the .exe file directly).
    Well to me, it would be unexpected that an application running under a debugger (or any integrated environment) would run at the same speed as running straight from the command prompt or from Windows Explorer.

    The debugger has to load symbols, output messages to the VS output window, etc. It would be natural to suspect that running under a debugger should add some overhead somewhere.

    Read this:

    http://blogs.msdn.com/b/larryosterma...heisenbug.aspx

    Maybe that explains your issue?

    Regards,

    Paul McKenzie

  5. #20
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Kofan View Post
    VladimirF, if the thread has the highest priority, it wil get the next quantum of CPU time. Otherwise, a thread can wait long enough, because the processor will work with other threads that have a higher priority (it can be the OS-threads or threads of other applications).
    As I asked above:
    You are saying that your threads (with normal priorities) are NOT utilizing CPU at 100%? What are they waiting for if no one else is using that CPU?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  6. #21
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Kofan View Post
    The interface-thread is synchronized with the work-threads using "join" method of std::thread (tbb::thread) class. Shared data synchronized with tbb::mutex.
    join should not be used in the ui thread because it blocks the ui thread and prevents it from pumping messages as mentioned earlier.

    The recommended approach is to have the worker thread use a user defined message and PostMessage to signal the ui thread when the work has completed.
    Last edited by Arjay; January 12th, 2012 at 03:27 PM.

  7. #22
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by Arjay View Post
    ...
    The recommended approach is to have the worker thread use a user defined message and sendmessage to signal the ui thread when the work has completed.
    Arjay, did you mean PostMessage?
    Victor Nijegorodov

  8. #23
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: The strange performance of Visual C++ application

    Quote Originally Posted by VictorN View Post
    Arjay, did you mean PostMessage?
    Yes. Thanks Victor, I fixed it.

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured