Anything related to processor affinity, also known as CPU pinning. The processor affinity is a propriety of a process or a thread in an OS on multi-processor or multi-core systems that influences the OS' scheduling algorithm, binding the execution of that process (or thread) to a specific processor (or core). DO NOT use this tag as a synonym for [affinetransform] tag.
Questions tagged [affinity]
330 questions
4
votes
1 answer
Set CPU Affinity in PHP?
Pretty straightforward question - is there a way to set the CPU affinity via PHP? Any of the following will do:
Setting the affinity of the current process via a PHP call.
Setting the affinity of a specific PID via a PHP call.
As a last resort,…

rinogo
- 8,491
- 12
- 61
- 102
4
votes
4 answers
Code for detecting APIC id returns same ids for different logical processors
I run my NT service on an Intel Core2 based Win2k3 machine where I need to iterate through all logical CPUs (all bits in process affinity). To do so I call GetProcessAffinityMask() to retrieve the system affinity mask and then switch the process to…

sharptooth
- 167,383
- 100
- 513
- 979
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…

vulcan raven
- 32,612
- 11
- 57
- 93
4
votes
4 answers
Is there a way to set thread affinity to a processor core with the boost thread library?
And would it be a good idea to do so if I needed the processor cores running on 100% for a dozen seconds or would I get better performance if I let the system decide how to handle the threads?
What I need is fast execution and I'm worried the system…

Kesarion
- 2,808
- 5
- 31
- 52
3
votes
2 answers
Setting affinity in multicore x86 processors
( I ask because it was before serious SMP and multicore that I studied OS. I like to have some vision of how code is being executed. )
If I have a multicore x86 CPU booting directly into my program. Can someone recommend a website which describes…

BubbaT
- 1,810
- 4
- 21
- 24
3
votes
3 answers
Why would you need to know about each processor in particular?
I'm curious to understand what could be the motivation behind the fine-grained detail of each virtual processor that the Windows 8 task manager seems to be focusing on.
Here's a screenshot (from here):
I know this setup could only…

Camilo Martin
- 37,236
- 20
- 111
- 154
3
votes
1 answer
Get process and thread affinity mask on Linux
On Windows, there exists the GetProcessAffinityMask API call, and there also exists a roundabout way of finding the thread affinity mask, seen here:
Query thread (not process) processor affinity?
Is there any way of getting this information in…

ahelwer
- 1,441
- 13
- 29
3
votes
2 answers
setting processor affinity with C++ that will run on Linux
Possible Duplicate:
CPU Affinity
I'm running on Linux and I want to write a C++ program that will set 2 specific processors that my 2 applications that will run in parallel (i.e. setting each process to run on a different core/CPU). I want to use…

Ifeanyi
- 41
- 1
- 1
- 4
3
votes
3 answers
How can I programatically set the affinity of all running processes in WIndows 7?
Is there any way to set the affinity for all running processes in Windows 7?
I want to run some hyperthreading benchmarks, and I want to ensure that they're running alone on a certain core. I'm running them with a wrapper, and I want to do…

Nathan Fellman
- 122,701
- 101
- 260
- 319
3
votes
1 answer
How to assign cpu affinity for Python 3 subprocess?
I am very much a novice at Python.
I am running a Tkinter GUI on Windows 7 and Windows 10. I have a subprocess running a data logger routine at 1 KHz. I would like to set a cpu affinity for the subprocess,
I am building with Python 3.8.

PEJ
- 31
- 2
3
votes
3 answers
Java: Will a looping Thread.sleep() always run on the same physical core?
I'm trying to understand Java internals about their scheduling and thread affinity.
The question is:
given an infinite loop, running on a thread as such in a multicore environment (e.g. 8):
while(true) Thread.sleep(1000);
Will this operation…

M4rk
- 2,172
- 5
- 36
- 70
3
votes
0 answers
Why is an infinite loop sleeping mostly on an isolated core?
I tried the following code to give all execution time by isolating CPU on Centos 8:
#include
#include
#include
int main()
{
volatile uint32_t i = 0;
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
…

avatli
- 610
- 6
- 16
3
votes
1 answer
Using multiple CPU cores in TensorFlow
I have extensively studied other answers on TensorFlow and I just cannot seem to get it to use multiple cores on my CPU.
According to htop, the following program only uses a single CPU core:
import tensorflow as tf
n_cpus = 20
sess =…

Elliott Slaughter
- 1,455
- 19
- 27
3
votes
1 answer
How to properly use TSX-NI (both HLE and RTM) when threads might switch cores?
It seems that Intel's Transactional Synchronization Extensions (TSX-NI) work on a per-CPU basis.
This applies to both the _InterlockedXxx_HLE{Acquire,Release} Hardware Lock Elision functions (HLE), as well as for the _xbegin/_xend/etc. Restricted…

user541686
- 205,094
- 128
- 528
- 886
3
votes
2 answers
How can I set a thread's CPU affinity in Qt5?
Working with threads in Qt5, how can I set a single thread's CPU affinity?
I want to specify a mask of available CPU cores that the thread may run under.
In other words, what is the Qt5 equivalent to Posix thread's pthread_setaffinity_np() ?
Can I…

Mr. Developerdude
- 9,118
- 10
- 57
- 95