Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2006 Jun : Re: SetThreadAffinityMask

www.cryer.info
Managed Newsgroup Archive

Re: SetThreadAffinityMask

Subject:Re: SetThreadAffinityMask
Posted by:"Jolyon Smith" (jolyo..@softtech.co.newzealand)
Date:Fri, 30 Jun 2006 08:41:23 +1200

In article <44a429ff@newsgroups.borland.com>, td34qz@gmx.de says...

> So it appears to be no way around running tests on various systems.

That's what we found - fortunately we had a fixed set of environments:

- single processor development kit
- dual processor test kit
- quad processor deployment kit

We put the required thread configuration info in a config file which was
read and applied at startup.


> however once the process affinity mask is
> changed all threads seem to inherit that mask.

It's not really "inheriting" as such, just limiting.

If you restrict a process to run on a specific CPU or set of CPU's, it
follows that threads in that process cannot run on any CPU that the
process itself is not allowed to.

But what you can do is allocate a thread to a specific subset of the
process CPU's.

e.g. In a 4x processor system, if you assign process affinity to CPU0
and CPU1, then you can assign thread affinity to either one or both of
these CPU's but NOT to CPU2 or CPU3.

Typically you would use EITHER process affinity to effectively mask all
threads in a process, OR thread affinity to mask specific threads, not
both.

<shrug>


> I've also not yet
> found a way to get thread's current mask :(

Not something I've ever needed to do (and to be honest can't think how
the information would be useful), but google on NTQueryThreadInformation
- there is a page on undocumented NTDLL calls that looks like it might
be helpful.


hth

--
Jolyon Smith

Replies:

none

In response to:

www.cryer.info
Managed Newsgroup Archive