Thread.SetProcessorAffinity Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
In the .NET Compact Framework for Xbox 360, sets the processor affinity for a managed thread. Processor affinity determines the processors on which a thread runs.
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public Sub SetProcessorAffinity ( _
ParamArray cpus As Integer() _
)
public void SetProcessorAffinity(
params int[] cpus
)
Parameters
- cpus
Type: array<System.Int32[]
An array of identifiers that specify the hardware threads on which the managed thread is permitted to run.
For Xbox 360, only a single hardware thread can be specified—the cpus array should contain only one element. The hardware thread number must be in the range 0 through 5.
XNA Game Studio Express games should not use hardware threads 0 or 2; see Remarks.
Remarks
Note: |
---|
This member is available only when developing for the Xbox 360. The most up-to-date information can be found in the documentation for XNA Game Studio Express. |
Each of the Xbox 360's three CPU cores has two hardware threads; the hardware thread number selects a specific hardware thread on a specific core. Hardware threads 0 and 1 are the hardware threads on core 0; 2 and 3 are the hardware threads on core 1; and 4 and 5 are the hardware threads on core 2.
Hardware Thread Number |
Core |
---|---|
0 or 1 |
0 |
2 or 3 |
1 |
4 or 5 |
2 |
Xbox 360 software threads are associated with, and run on, only a single hardware thread at a time. The hardware thread on which a thread runs (the thread's processor affinity) must be set to a single hardware thread, but can be subsequently changed by calling SetProcessorAffinity with a different hardware thread number. When a thread is created, it is initially assigned to the current hardware thread (that is, the hardware thread on which the current thread is running).
For Xbox 360 threads, you cannot clear the thread's processor affinity by passing an empty array as the cpus parameter. An Xbox 360 thread will always be associated with one hardware thread.
XNA Game Studio Express games should not use hardware threads 0 or 2, which are reserved for the XNA Framework. The following table identifies Xbox 360 hardware thread usage.
Hardware Thread |
Available |
---|---|
0 |
No, reserved for XNA Framework. |
1 |
Yes |
2 |
No, reserved for XNA Framework. |
3 |
Yes |
4 |
Yes |
5 |
Yes |
To determine the number of hardware threads supported by the hardware, use the Environment.ProcessorCount property.
This method should not be used with threads that belong to the managed thread pool. See The Managed Thread Pool.
Version Information
XNA Framework
Supported in: Xbox 360
Platforms
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.