Bug: Reduced exceptions during cpu core init Bug: GetSensorValuesFromSettings, Sensors.cs reduced number of exceptions Bug: HTTP Server Null Reference Exception on StopHTTPListener Bug: in some cases 64 bit process on a 32Bit system detected Intel CPUs: Max Temperature Sensor from all Cores Average temperature from all core sensors dist to tjmax sensor for each core AMD: support new cpus bugfix power sensors Mainboards: Asrock: AB350 PRO4 AB350M PRO4 AB350M Fatal1ty AB350 Gaming K4 AB350M HDV Phantom Gaming 6 A320M-HDV Asrock Z77 Pro4-M Asus: ASUS ROG ZENITH EXTREME (X399) Z170-A Gigabyte: GIGABYTE X399 AOURUS GAMING7
66 lines
1.9 KiB
C#
Executable File
66 lines
1.9 KiB
C#
Executable File
/*
|
|
|
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
Copyright (C) 2010-2014 Michael Möller <mmoeller@openhardwaremonitor.org>
|
|
|
|
*/
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace OpenHardwareMonitor.Hardware {
|
|
|
|
internal static class ThreadAffinity {
|
|
|
|
public static ulong Set(ulong mask) {
|
|
if (mask == 0)
|
|
return 0;
|
|
|
|
if (Software.OperatingSystem.IsLinux)
|
|
{ // Unix
|
|
ulong result = 0;
|
|
if (NativeMethods.sched_getaffinity(0, (IntPtr)Marshal.SizeOf(result),
|
|
ref result) != 0)
|
|
return 0;
|
|
if (NativeMethods.sched_setaffinity(0, (IntPtr)Marshal.SizeOf(mask),
|
|
ref mask) != 0)
|
|
return 0;
|
|
return result;
|
|
} // Windows
|
|
UIntPtr uIntPtrMask;
|
|
try {
|
|
uIntPtrMask = (UIntPtr)mask;
|
|
} catch (OverflowException) {
|
|
throw new ArgumentOutOfRangeException("mask");
|
|
}
|
|
return (ulong)NativeMethods.SetThreadAffinityMask(
|
|
NativeMethods.GetCurrentThread(), uIntPtrMask);
|
|
}
|
|
|
|
private static class NativeMethods {
|
|
private const string KERNEL = "kernel32.dll";
|
|
|
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
public static extern UIntPtr
|
|
SetThreadAffinityMask(IntPtr handle, UIntPtr mask);
|
|
|
|
[DllImport(KERNEL, CallingConvention = CallingConvention.Winapi)]
|
|
public static extern IntPtr GetCurrentThread();
|
|
|
|
private const string LIBC = "libc";
|
|
|
|
[DllImport(LIBC)]
|
|
public static extern int sched_getaffinity(int pid, IntPtr maskSize,
|
|
ref ulong mask);
|
|
|
|
[DllImport(LIBC)]
|
|
public static extern int sched_setaffinity(int pid, IntPtr maskSize,
|
|
ref ulong mask);
|
|
}
|
|
}
|
|
}
|
|
|