Questions tagged [setthreadaffinitymask]

25 questions
64
votes
5 answers

Java thread affinity

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…
Dave
  • 1,350
  • 3
  • 15
  • 25
5
votes
2 answers

set thread affinity in a linux kernel module

as most C programmers know libc gives a non portable functions for thread cpu affinity tuning (pthread_attr_setaffinity_np()). However, what I do not really know is how can this be done when implementing a kernel module. Any answer that mentions or…
user1533288
  • 221
  • 3
  • 6
4
votes
1 answer

Why does NextValue call of performanceCounter change thread affinity mask

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…
Boris
  • 4,884
  • 4
  • 41
  • 71
4
votes
1 answer

Process affinity in Windows Phone

I WP library project, I am trying to bind the heavy-lifting process to the hardware thread (0 or 1). So the app consuming the library use other available core. Can we set process affinity in Windows Phone 8 app? I cannot find documentation on…
3
votes
6 answers

What good are thread affinity mask changes for the current thread?

I'm writing a game engine and I need a way to get a precise and accurate "deltatime" value from which to derive the current FPS for debug and also to limit the framerate (this is important for our project). Doing a bit of research, I found out one…
Gui Prá
  • 5,119
  • 3
  • 29
  • 54
2
votes
1 answer

Windows SetThreadAffinityMask has no effect

I have written a small test program in which I try to use the Windows API call SetThreadAffinityMask to lock the thread to a single NUMA node. I retrieve the CPU bitmask of a node with the GetNumaNodeProcessorMask API call, then pass that bitmask to…
ahelwer
  • 772
  • 5
  • 23
2
votes
1 answer

Pthread_setaffinity_np invalid argument

I am trying to change the affinity of each thread inside the start routine. Here's the code. In the below code, 't' is the argument passed through the pthread_create function. cpu_set_t mask; pthread_t c; a = *((int *)t); printf("…
akhil28288
  • 172
  • 1
  • 13
1
vote
3 answers

SetThreadAffinityMask is ignored....any ideas?

Update: I found the problem - embarrassingly/ironically enough it was was calling SetThreadAffinity() in the wrong thread, not the main one (program startup is messy...) It's all working now, thanks for all the help! I've given everybody an upvote…
Jimmy J
  • 1,885
  • 1
  • 13
  • 20
1
vote
1 answer

Check value of PF_NO_SETAFFINITY

Is it possible to tell whether a process/thread has the PF_NO_SETAFFINITY flag set? I'm running taskset on a series of process ids and some are throwing errors of the following form: taskset: failed to set pid 30's affinity: Invalid argument I…
Will
  • 902
  • 1
  • 9
  • 20
1
vote
2 answers

SethreadAffinityMask() correct usage?

I have 1500 threads..I want them to run on 12 processors... To do that I call SetThreadAffinityMask(GetCurrentThread(),1<<(threadnum%numprocessors)); where numprocessors=12. Is that correct usage of the mask? It needs to be scalable, that is if i…
Jake
  • 2,737
  • 8
  • 39
  • 60
1
vote
0 answers

Wake up sleeping CPU for sched_setaffinity on android

I work on application which runs several threads, one thread is most important and must run on strongest cpu. I successfully attach this thread to chosen cpu with c++ function sched_setaffinity. syscallres = syscall(__NR_sched_setaffinity, pid,…
user1063364
  • 554
  • 5
  • 13
1
vote
1 answer

pthreads_setaffinity_np: Invalid argument?

I've managed to get my pthreads program sort of working. Basically I am trying to manually set the affinity of 4 threads such that thread 1 runs on CPU 1, thread 2 runs on CPU 2, thread 3 runs on CPU 3, and thread 4 runs on CPU 4. After compiling,…
hahuang65
  • 2,034
  • 6
  • 27
  • 36
1
vote
2 answers

Obtain LWP id from a pthread_t on Solaris to use with processor_bind

On Solaris, processor_bind is used to set affinity for threads. You need to know the LWPID of the target thread or use the constant P_MYID to refer to yourself. I have a function that looks like this: void set_affinity(pthread_t thr, int…
Wez Furlong
  • 3,878
  • 23
  • 32
1
vote
1 answer

Windows.h thread affinity

The code below does compile and run except that the output is not what I expect it to be. I wanted the program to create n-number of threads (depending on the number of multicores available) and run a simple routine found at the end of the program…
pandoragami
  • 4,857
  • 14
  • 57
  • 100
0
votes
0 answers

CPU thread affinity set, will the OS scheduler give less job to the set cpu core from jobs of non set thread?

assuming I have a 18 core cpu, and in my c++ program I set thread affinity for two thread for core 3, 4 by pthread_setaffinity_np. Does that mean when operating system schedule jobs for other program or thread in the same program, it will schedule…
tesla1060
  • 2,115
  • 5
  • 23
  • 40
1
2