running thread on specified core
Hi all, :wave:
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!
Re: running thread on specified core
Take a look at SetThreadAffinityMask.
- petter
Re: running thread on specified core
aha.. that's exaclty what I was looking for. Now to put it in action :)
Thanks!
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
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. :D
Re: running thread on specified core
Quote:
Originally Posted by vma
Hi all, :wave:
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.
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.