diff --git a/Common/Cdy.Tag.Common/Common/ThreadHelper.cs b/Common/Cdy.Tag.Common/Common/ThreadHelper.cs
index 01e829b352b878aa13dd6869a8f528e59268e47b..c79e4aa730ea48b41a480c67abb8468c6ba26fc0 100644
--- a/Common/Cdy.Tag.Common/Common/ThreadHelper.cs
+++ b/Common/Cdy.Tag.Common/Common/ThreadHelper.cs
@@ -61,7 +61,7 @@ namespace Cdy.Tag
}
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
-
+ SetThreadAffinityMaskLinux(MaskFromIds(cpus));
}
else
{
@@ -81,7 +81,9 @@ namespace Cdy.Tag
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
-
+ //ulong re = 0;
+ //LinuxNative.pthread_getaffinity_np(LinuxNative.pthread_self(), ref re);
+ //return (uint)re;
}
else
{
@@ -115,6 +117,16 @@ namespace Cdy.Tag
//return SetThreadAffinityMask(Win32Native.GetCurrentThread(), mask);
}
+
+ ///
+ ///
+ ///
+ ///
+ public static void SetThreadAffinityMaskLinux(ulong mask)
+ {
+ LinuxNative.pthread_setaffinity_np(LinuxNative.pthread_self(),8,ref mask);
+ }
+
///
/// Masks from ids.
///
@@ -166,6 +178,38 @@ namespace Cdy.Tag
#endregion ...Interfaces...
}
+ public static class LinuxNative
+ {
+ private const string pthread = "libpthread.so.0";
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(pthread, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern int pthread_setaffinity_np(IntPtr threadHandel, int cpusize,ref UInt64 cpuset);
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ [DllImport(pthread, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern int pthread_getaffinity_np(IntPtr threadHandel,ref UInt64 cpuset);
+
+ ///
+ ///
+ ///
+ ///
+ [DllImport(pthread, CharSet = CharSet.Auto, SetLastError = true)]
+ public static extern IntPtr pthread_self();
+ }
+
+
///
/// Win32Native Class
///