Udostępnij za pośrednictwem


Metoda CpuCollection.SetAffinityToRange (Int32, Int32, Boolean)

Ustawia maski koligacji procesorów w określonym zakres.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Składnia

'Deklaracja
Public Sub SetAffinityToRange ( _
    startCpuId As Integer, _
    endCpuId As Integer, _
    affinityMask As Boolean _
)
'Użycie
Dim instance As CpuCollection
Dim startCpuId As Integer
Dim endCpuId As Integer
Dim affinityMask As Boolean

instance.SetAffinityToRange(startCpuId, _
    endCpuId, affinityMask)
public void SetAffinityToRange(
    int startCpuId,
    int endCpuId,
    bool affinityMask
)
public:
void SetAffinityToRange(
    int startCpuId, 
    int endCpuId, 
    bool affinityMask
)
member SetAffinityToRange : 
        startCpuId:int * 
        endCpuId:int * 
        affinityMask:bool -> unit 
public function SetAffinityToRange(
    startCpuId : int, 
    endCpuId : int, 
    affinityMask : boolean
)

Parametry

  • startCpuId
    Typ: System.Int32
    int Od 0 do Count -1, który określa początek z zakres z procesorów.Jeśli startIndex jest nie do prawidłowego zakres, zwracany jest następujący wyjątek: Specified argument was out of the range of valid values. Parameter name: startIndex.
  • endCpuId
    Typ: System.Int32
    int , Który określa endIndex zakres. endIndexmusi być większa lub równa startIndex i mniej niż [P:Microsoft.SqlServer.Management.Smo.CpuCollection.Count.]
    Jeśli endIndex jest nie do prawidłowego zakres, zwracany jest następujący wyjątek: Specified argument was out of the range of valid values. Parameter name: endIndexd.
    Jeśli endIndex jest mniejsza niż startIndex, zwróciła następujący wyjątek: The specified range of CPUs is not valid. The value for startIndex must be less than the value for endIndex.
  • affinityMask
    Typ: System.Boolean
    Jeśli true, koligacja jest zestaw do każdego procesora CPU w określonym zakresie.Jeśli false, koligacja jest usuwana z każdego Procesora w określonym zakres.

Przykłady

W poniższym przykładzie jak zestaw koligacji każdego Procesora na wystąpienie SQL Server.

C#

using System;
using System.Collections.Specialized;
using System.Data;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Server dbServer = new Server("(local)");
            dbServer.AffinityInfo.AffinityType = AffinityType.Manual;
            dbServer.AffinityInfo.Alter();
            dbServer.AffinityInfo.Cpus.SetAffinityToRange(0, 
                dbServer.AffinityInfo.Cpus.Count-1,
                true);
        }
    }
}

PowerShell

$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Manual'
$dbServer.AffinityInfo.Alter()
$dbServer.AffinityInfo.Cpus.SetAffinityToRange(0, $dbServer.AffinityInfo.Cpus.Count-1, $TRUE)