setthreadaffinitymask

Why does NextValue call of performanceCounter change thread affinity mask

我是研究僧i 提交于 2019-12-23 12:26:45
问题 I have a C# project, where I have to both access the current workload of my processor, and ensure, that I run some specific code on every kernel of the processor. My problem is, that accessing the workload of my processor seems to prevent me from correctly assigning a thread affinity mask. I have some code here, that illustrates the problem: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; using System.Diagnostics;

Java thread affinity

淺唱寂寞╮ 提交于 2019-11-26 01:39:30
问题 Does anybody know of a way to lock down individual threads within a Java process to specific CPU cores (on Linux)? I\'ve done this in C, but can\'t find how to do this in Java. My instincts are that this will require a JNI call, but I was hoping someone here might have some insight or might have done it before. Thanks! 回答1: You can't do this in pure java. But if you really need it -- you can use JNI to call native code which do the job. This is the place to start with: http://ovatman.blogspot