CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    running thread on specified core

    Hi all,
    Is ii possible to run a thread on a specified core? I have an application that receives images from a video cammera and applies some algorithms on these images before display on the screen. Because it critical that I don't loose any frame I was thinking about using one core to aquire images from the frame grabber and the other core to apply algorithms... Is that possible?
    Thanks!
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: running thread on specified core

    Take a look at SetThreadAffinityMask.

    - petter

  3. #3
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    Re: running thread on specified core

    aha.. that's exaclty what I was looking for. Now to put it in action

    Thanks!
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

  4. #4
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: running thread on specified core

    It's usually a mistake to try and second-guess the built-in thread scheduler of Windows. It almost always can do a better job than you can.

    Let us know if your idea works. It might turn out to be an example of a situation where the programmer does a better job than the scheduler.

    Mike

  5. #5
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    673

    Re: running thread on specified core

    Hmm, what if that core which you specified is busy with other single thread application or other application also specified that core or 2 and more instances of your application is running. I also don't know what may have happened in these scenario.

    You will never know what applications are running on your users' machines, unless this application always run in a controlled environment, for example, application to control the running of a machine in a factory.

    Let me know too if the processor affinity method work.

  6. #6
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: running thread on specified core

    Quote Originally Posted by vma
    Hi all,
    Is ii possible to run a thread on a specified core? I have an application that receives images from a video cammera and applies some algorithms on these images before display on the screen. Because it critical that I don't loose any frame I was thinking about using one core to aquire images from the frame grabber and the other core to apply algorithms... Is that possible?
    Thanks!
    Have you experienced frame losts when the threads are scheduled on cores by the OS? The approach you proposed is not error-proof, like the other mentioned. I think the chances are it won't work better.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  7. #7
    Join Date
    Oct 2003
    Location
    Timisoara, Romania
    Posts
    460

    Re: running thread on specified core

    Thanks for your observations... What to say? I will give it a try and see what happens I will let you know if it worked better or not The thing is that there is an application for a microcontroller and the final client is this. There we don't have this problem as there is no other procees like on the PC. But my application will be on PC and it is just to test the algorithms that will go into this microcontroller.
    Last edited by vma; February 22nd, 2008 at 02:22 AM.
    You liked it? Please show your gratitude and rate it!

    There is no 'patch' for stupidity.

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