Jump to content
  • Advertisement
Sign in to follow this  
wh1sp3rik

windows threads

This topic is 2748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,
I have few questions about threads.

Let's say, i have 4core cpu and i will create 4 threads by CreateThread function.
It will create thread on every my core.

Now, what if i want to create 5. thread ? what core will run this thread ?
I would like to select a core to make a thread on them somehow, is it possible ? becuase i would like to have few cores for max cpu speed. if i create 5. thread, i don't know, which core do multitasking with my 5. thread.

Thank you very much for answers ;-)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by wh1sp3rik
Let's say, i have 4core cpu and i will create 4 threads by CreateThread function.
It will create thread on every my core.


Not necessarily. It is up to the operating system's scheduler to decide when each thread gets time on a CPU.

Quote:

Now, what if i want to create 5. thread ? what core will run this thread ?

Same answer.

Quote:

I would like to select a core to make a thread on them somehow, is it possible ?


You can pin a thread to a core (using e.g. SetThreadAffinityMask on Windows) but you cannot pin a core to a thread, as that would allow a user-land application to clog up the whole system (a DOS attack). However, even pinning a thread to a core is still reasonably unusual and you should probably avoid it in general. AFAIK, SetThreadAffinityMask is also only a strong hint rather than a decree.

Quote:

becuase i would like to have few cores for max cpu speed. if i create 5. thread, i don't know, which core do multitasking with my 5. thread.

Let the operating system handle the scheduling.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!