private static bool rdmsrWindows(uint index, out ulong value, ulong threadAffinityMask = 0) { value = 0; if (driver == null) { return(false); } // Force current thread to run on the requested CPU core // This probably works because the kernel processes short running requests on // the CPU thread where they originated from to improve efficiency. While this // is probably a likely hack, changing this behavior would require significant // changes to the kernel driver. ulong mask = 0xFFFFFFFFFFFFFFFF; if (threadAffinityMask != 0) { mask = ThreadAffinity.Set(threadAffinityMask); } try { // Communicate with WinRing0 driver return(driver.DeviceIOControl(IOCTL_OLS_READ_MSR, index, ref value)); } finally { if (threadAffinityMask != 0) { ThreadAffinity.Set(mask); } } }
public static bool RdmsrTx(uint index, out uint eax, out uint edx, ulong threadAffinityMask) { ulong mask = ThreadAffinity.Set(threadAffinityMask); bool result = Rdmsr(index, out eax, out edx); ThreadAffinity.Set(mask); return(result); }
public static bool RdmsrTx(uint index, out uint eax, out uint edx, GroupAffinity affinity) { var previousAffinity = ThreadAffinity.Set(affinity); bool result = Rdmsr(index, out eax, out edx); ThreadAffinity.Set(previousAffinity); return(result); }
public static bool CpuidTx(uint index, uint ecxValue, out uint eax, out uint ebx, out uint ecx, out uint edx, ulong threadAffinityMask) { ulong mask = ThreadAffinity.Set(threadAffinityMask); if (mask == 0) { eax = ebx = ecx = edx = 0; return(false); } Cpuid(index, ecxValue, out eax, out ebx, out ecx, out edx); ThreadAffinity.Set(mask); return(true); }
public static bool CpuidTx(uint index, uint ecxValue, out uint eax, out uint ebx, out uint ecx, out uint edx, GroupAffinity affinity) { var previousAffinity = ThreadAffinity.Set(affinity); if (previousAffinity == GroupAffinity.Undefined) { eax = ebx = ecx = edx = 0; return(false); } Cpuid(index, ecxValue, out eax, out ebx, out ecx, out edx); ThreadAffinity.Set(previousAffinity); return(true); }
public static ulong ThreadAffinitySet(ulong mask) { return(ThreadAffinity.Set(mask)); }