Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

walkingcarcass

threads and multiprocessors

This topic is 5772 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

can a process get the handle of it''s primary thread? on a multiprocessor system, how can I tell which processor is being used? CPUID may have identical results on both. also, can execution be forced to switch processors? ******** A Problem Worthy of Attack Proves It''s Worth by Fighting Back

Share this post


Link to post
Share on other sites
Advertisement
quote:

can a process get the handle of it''s primary thread


You can use GetCurrentThread() to get the current thread (surprisingly ), and you can use GetWindowThreadProcessId() To get the thread that created the apps window (which is usually the default thread)

quote:

can execution be forced to switch processors?


I dunno if it can be *forcd* to, but you can use SetThreadIdealProcessor().

HTH

Share this post


Link to post
Share on other sites
quote:
Original post by walkingcarcass
can a process get the handle of it''s primary thread?



You may give a look at GetCurrentThread() and GetCurrentThreadId() functions.

quote:

on a multiprocessor system, how can I tell which processor is being used? CPUID may have identical results on both.



Why would you need this anyway ? Could you explain what you want to do ?

quote:

also, can execution be forced to switch processors?



I don''t know but the SetThreadAffinityMask() function allows you to choose processors that a thread is allowed to run on.

Share this post


Link to post
Share on other sites
multiprocessor knowledge is important if eg RDTSC is used, or one processor can''t execute certain instructions

would this work: allowing only one processor to be used, calling Sleep(0) then changing the legal processor etc?

********


A Problem Worthy of Attack
Proves It''s Worth by Fighting Back

Share this post


Link to post
Share on other sites
quote:
Original post by walkingcarcass
multiprocessor knowledge is important if eg RDTSC is used, or one processor can''t execute certain instructions

would this work: allowing only one processor to be used, calling Sleep(0) then changing the legal processor etc?



SMP - symmetric multiprocessing, which is what most multiprocessor PCs have (including mine) assume that both processors are identical (in functionality). As for functions that rely on CPU state that is not part of the execution context ... I don''t have a solution (though you could run these functions as ''asynchronous functions'' running in a dedicated thread which would be only permitted to run on one processor).

As for changing the affinity mask, yeah, it would work, potentially even without calling Sleep(), though the change would only occur the next time the thread is re-scheduled to run.


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!