Questions tagged [affinity]

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.

330 questions
3
votes
1 answer

Alternative to shed_getaffinity, cpu_set_t etc?

So I'm a noob when it comes to this sort of stuff. I'm struggling to compile a climate model on macOS and I've boiled it down to what is going on here: #define _GNU_SOURCE #include #include #include #include…
Neil Lewis
  • 31
  • 1
  • 2
3
votes
1 answer

Python 3 on macOS: how to set process affinity

I am trying to restrict the number of CPUs used by Python (for benchmarking & to see if it speeds up my program). I have found a few Python modules for achieving this ('os', 'affinity', 'psutil') except that their methods for changing affinity only…
Aki
  • 155
  • 1
  • 2
  • 8
3
votes
3 answers

Mapping logical processors to physical processors

On a dual quad-core GetProcessAffinityMask (or the dialog from "Set affinity" in taskman.exe) will report eight logical processors. How do I find out which logical processor is on which physical processor? Especially: which logical processors are on…
Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
3
votes
1 answer

Set thread affinity on two cores using OpenMP

I am using a C program, compiled with gcc 4.9.2 on Windows7, using OpenMP 4.0. My computer is dual core, with four threads. I'd like to use thread affinity spread and use 2 threads put on different cores. So when I set the environment variables from…
Franktrt
  • 373
  • 1
  • 8
  • 18
3
votes
2 answers

Linux - make sure a core is exclusively saved for critical tasks

I have a process that is launched on a Linux-based machine with exactly two cores. Let's assume my process is the only process in the system (I will ignore other processes and even the system's ones). My process is divided to two parts: Critical…
Itay Marom
  • 801
  • 6
  • 15
3
votes
2 answers

Processor affinity settings for Linux kernel modules?

In Windows, I can set the processor affinity of driver code using KeSetSystemAffinityThread, and check which processor my code is running on using KeGetCurrentProcessorNumber. I'm trying to do something similar in a Linux kernel module, but the only…
Stephen
  • 4,176
  • 2
  • 24
  • 29
3
votes
1 answer

How to imitate finishAffinity in Android?

The question is pretty self explanatory. I'm doing a class that registers the activity of the user in order to avoid inactivity, after 2 minutes of no activity or everytime the user minimizes the app, the app should close. My code is the one listed…
Razvi
  • 400
  • 4
  • 17
3
votes
1 answer

Interaction between taskset and sched_setaffinity

Could anyone tell me what would occur if I ran taskset -c 7 ./fred.x but then inside fred.x a thread is calling sched_setaffinity to bind to core 6? Would that thread get ANY cpu time ever, or will it remain idle indefinitely?
Derf Skren
  • 479
  • 2
  • 22
3
votes
2 answers

Set processor affinity for current thread on Mono (Linux)

I'm writing a custom task scheduler, and I would like to know if there is any way of setting the processor affinity for the current thread on Mono (running on Linux). For the .NET runtime running on Windows, I've managed to get this to work by…
Douglas
  • 53,759
  • 13
  • 140
  • 188
3
votes
3 answers

Pros and Cons of CPU affinity

Suppose I have a multi-threaded application (say ~40 threads) running on a multiprocessor system (say 8 cores) with Linux as the operating system where different threads are more essentially LWP (Light Weight Processes) being scheduled by the…
Vivek Gupta
  • 213
  • 4
  • 10
3
votes
2 answers

Setting application affinity in gdb

Is there a simple way of setting the affinity of the application I'm debugging without locking gdb to the same core? The reason why I'm asking is that the application is running with real time priority and it needs to run on a single core. At the…
Marcus Ahlberg
  • 1,329
  • 2
  • 11
  • 24
3
votes
5 answers

Why is it that restricting multithreaded applications to one core make it run faster?

I have a native multithreaded Win32 application written in C++ which has about 3 relatively busy threads and 4 to 6 threads that don't do that much. When it runs in a normal mode total CPU usage adds up to about 15% on an 8-core machine and the…
detunized
  • 15,059
  • 3
  • 48
  • 64
2
votes
2 answers

How to enforce CPU Socket affinity?

I know that there are ways to enforce thread/process affinity to bind a particular thread/process to a CPU/core in various OSs. I am just wondering if there is a way to enforce the CPU Socket affinity. i.e. to enforce a thread/process to be bound to…
Jay D
  • 3,263
  • 4
  • 32
  • 48
2
votes
1 answer

failure-domain.beta.kubernetes.io/region label missing in my nodes makes deployment not find the PV in Azure AKS service

In a Azure AKS kubernetes cluster, after a cluster version upgrade the nodepool nodes, I have a PV that has this node affinity: Node Affinity: Required Terms: Term 0: failure-domain.beta.kubernetes.io/region in [westeurope] The nodes…
2
votes
0 answers

How to create threads only on performance cores in MAC OSX on Apple silicon?

does anyone of you know, how to create threads only on performance cores under Apple OSX with new asymmetric core Apple chips (M1, M1 Pro...)? I am referencing these two guides from…