// ******************************************************************
 private void ButtonBaseOnClick(object sender, RoutedEventArgs e)
 {
     List <SystemInfoHelper.GROUP_RELATIONSHIP>     groupRelationShips     = SystemInfoHelper.GetLogicalProcessorInformationEx <SystemInfoHelper.GROUP_RELATIONSHIP>();
     List <SystemInfoHelper.GROUP_RELATIONSHIP>     numaRelationShips      = SystemInfoHelper.GetLogicalProcessorInformationEx <SystemInfoHelper.GROUP_RELATIONSHIP>();
     List <SystemInfoHelper.PROCESSOR_RELATIONSHIP> processorRelationShips = SystemInfoHelper.GetLogicalProcessorInformationEx <SystemInfoHelper.PROCESSOR_RELATIONSHIP>();
     List <SystemInfoHelper.GROUP_RELATIONSHIP>     cacheRelationShips     = SystemInfoHelper.GetLogicalProcessorInformationEx <SystemInfoHelper.GROUP_RELATIONSHIP>();
 }
        // ******************************************************************
        private void LooseYourTime(int index, DateTime until)
        {
            var processorNumber = new SystemInfoHelper.PROCESSOR_NUMBER();

            SystemInfoHelper.GetCurrentProcessorNumberEx(ref processorNumber);

            Interlocked.Increment(ref _threadCount);

            ThreadInfo ti = CollThreadInfo[index];

            ti.Index    = index;
            ti.ThreadId = Thread.CurrentThread.ManagedThreadId;
            ti.CurrentProcessorNumber = processorNumber.Number;
            ti.ProcessorGroup         = processorNumber.Group;

            double x, y;
            int    i = 1;

            while (IsRunning)
            {
                i = i + 1;

                PrimeTool.IsPrime(i);
                if (i == int.MaxValue)
                {
                    i = 0;
                    x = Math.Sqrt((double)i);
                    x = x + x;
                }

                ti.ThreadId = Thread.CurrentThread.ManagedThreadId;

                SystemInfoHelper.GetCurrentProcessorNumberEx(ref processorNumber);
                ti.CurrentProcessorNumber = processorNumber.Number;
                ti.ProcessorGroup         = processorNumber.Group;
            }
        }
 // ******************************************************************
 private void NonExOnClick(object sender, RoutedEventArgs e)
 {
     SystemInfoHelper.SYSTEM_LOGICAL_PROCESSOR_INFORMATION[] results = SystemInfoHelper.GetLogicalProcessorInformation();
 }
Beispiel #4
0
        public void Refresh()
        {
            WmiProcessorCount         = SystemInfoHelper.GetWmiPhysicalProcessorCount();
            WmiGlobalCoreCount        = SystemInfoHelper.GetWmiCoreCount();
            WmiLogicalProcessorCount  = SystemInfoHelper.GetWmiGlobalLogicalProcessorCount();
            NumaHighestNodeNumber     = SystemInfoHelper.GetNumaHighestNodeNumber();
            ActiveProcessorGroupCount = SystemInfoHelper.GetActiveProcessorGroupCount();

            var sb = new StringBuilder();

            for (UInt16 groupIndex = 0; groupIndex < ActiveProcessorGroupCount; groupIndex++)
            {
                if (sb.Length > 0)
                {
                    sb.AppendLine();
                }

                sb.AppendFormat("Group '{0}' as ", groupIndex);

                UInt32 processorCount = SystemInfoHelper.GetActiveProcessorCount(groupIndex);
                if (processorCount == 0)
                {
                    sb.AppendFormat("Error reading GetActiveProcessorCount: {0}", Marshal.GetLastWin32Error());
                }
                else
                {
                    sb.AppendFormat("{0} Logical Processors", processorCount);
                }
            }

            LogicalProcessorCountPerGroup = sb.ToString();

            MaximumProcessorGroupCount             = SystemInfoHelper.GetMaximumProcessorGroupCount();
            CSharpEnvironmentLogicalProcessorCount = Environment.ProcessorCount;

            UInt64 processAffinityMask;
            UInt64 systemAffinityMask;

            bool isResultOk = SystemInfoHelper.GetProcessAffinityMask(
                System.Diagnostics.Process.GetCurrentProcess().Handle,
                out processAffinityMask,
                out systemAffinityMask);

            if (isResultOk)
            {
                ProcessAffinityMask       = processAffinityMask;
                ProcessAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", processAffinityMask,
                                                          GetBitCount(processAffinityMask), GetBitString(processAffinityMask));
                SystemAffinityMask       = systemAffinityMask;
                SystemAffinityMaskString = String.Format("{0} (bit count: {1})\r\n{2}", systemAffinityMask,
                                                         GetBitCount(processAffinityMask), GetBitString(systemAffinityMask));
            }
            else
            {
                int error = Marshal.GetLastWin32Error();

                ProcessAffinityMaskString = "GetProcessAffinityMask() error = " + error;
                SystemAffinityMaskString  = "GetProcessAffinityMask() error = " + error;
            }

            sb.Clear();
            for (int nodeIndex = 0; nodeIndex <= NumaHighestNodeNumber; nodeIndex++)
            {
                UInt64 numaNodeProcessorMask;
                SystemInfoHelper.GetNumaNodeProcessorMask((byte)nodeIndex, out numaNodeProcessorMask);
                sb.Append(String.Format("Node: {0} Processor Mask: {1} (bit count: {2})", nodeIndex, numaNodeProcessorMask, GetBitCount(numaNodeProcessorMask)));
                sb.Append(Environment.NewLine);
                sb.Append(GetBitString(numaNodeProcessorMask));
                sb.Append(Environment.NewLine);
            }

            NumaNodeAndTheirAffinityMask = sb.ToString();

            var structLogProcInfo = SystemInfoHelper.GetLogicalProcessorInformation();
        }