affinity

These days, what are good reasons for setting thread affinity rather than leaving it to the OS?

末鹿安然 提交于 2019-12-22 12:48:25
问题 Searching answers here for "thread affinity", I see a lot of interest in doing it but little justification for it save possibly getting stable QueryPerformanceTimer results. Assuming a modern OS and a modern 2-4 socket workstation/server class machine with modern 4-6 core CPUs, what good reasons would anyone have for thinking they know better than their OS's scheduler ? Are there any real world situations where taking more control of thead affinity is the right thing to do ? What sort of

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

旧城冷巷雨未停 提交于 2019-12-21 05:42:14
问题 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 application finished in about 30 seconds. And when I restrict the application to only one core by setting the affinity mask to 0x01 it completes faster, in 23 seconds. I'm guessing it has something to do with the synchronization being cheaper when

Change affinity of process with windows script

有些话、适合烂在心里 提交于 2019-12-20 10:05:07
问题 In Windows, with START /node 1 /affinity ff cmd /C "app.exe" I can set the affinity of app.exe (number of cores used by app.exe). With a windows script, How I can change the affinity of a running process ? 回答1: PowerShell can do this task for you Get Affinity: PowerShell "Get-Process app | Select-Object ProcessorAffinity" Set Affinity: PowerShell "$Process = Get-Process app; $Process.ProcessorAffinity=255" Example: (8 Core Processor) Core # = Value = BitMask Core 1 = 1 = 00000001 Core 2 = 2 =

setting processor affinity with C++ that will run on Linux [duplicate]

情到浓时终转凉″ 提交于 2019-12-19 04:17:10
问题 This question already has answers here : Closed 8 years ago . 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 processor affinity tool with C++. Please can anyone help with C++ code. 回答1: From the command line you can use taskset(1), or from within your code you can use sched_setaffinity(2). E.g.

Set thread processor affinity in Microsoft .Net

两盒软妹~` 提交于 2019-12-17 18:43:08
问题 (Posting this with answer because I couldn't find a full explanation of how to do this anywhere, so I thought it might have some value for someone) How can I set the processor affinity of a particular thread in Microsoft .Net? Setting the process's affinity is trivial via System.Diagnostics.Process.ProcessorAffinity, but the System.Threading.Thread class offers no such functionality and .Net doesn't guarantee a managed thread is linked to any particular operating system thread. 回答1: The

Set affinity with start /AFFINITY command on Windows 7

自闭症网瘾萝莉.ら 提交于 2019-12-17 09:36:29
问题 I am using the start /AFFINITY [n] [.exe] command to start an executable with the specified affinity. I have a system with 8 processors (1,2,3,4,5,6,7,8). I'd like to set the process to use all of the odd processors (1,3,5,7). I cannot figure out how to do this and would like to know if it's possible using the start command. If not, is there an alternate command-line way of doing it? The help for the start command wasn't particularly useful: AFFINITY Specifies the processor affinity mask as a

how to set CPU affinity of a particular pthread?

时光总嘲笑我的痴心妄想 提交于 2019-12-17 02:54:37
问题 I'd like to specify the cpu-affinity of a particular pthread. All the references I've found so far deal with setting the cpu-affinity of a process (pid_t) not a thread (pthread_t). I tried some experiments passing pthread_t's around and as expected they fail. Am I trying to do something impossible? If not, can you send a pointer please? Thanks a million. 回答1: This is a wrapper I've made to make my life easier. Its effect is that the calling thread gets "stuck" to the core with id core_id : //

Multi-Processing

有些话、适合烂在心里 提交于 2019-12-13 03:17:27
手动分配CPU核 taskset -p f 1574 pid 1574's current affinity mask: 5 pid 1574's new affinity mask: f taskset -c busybox 不支持 cat /proc/cpuinfo Processor : ARMv7 Processor rev 5 (v7l) processor : 0 BogoMIPS : 5714.28 processor : 1 BogoMIPS : 5714.28 processor : 2 BogoMIPS : 5714.28 processor : 3 BogoMIPS : 5714.28 Features : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xc07 CPU revision : 5 Hardware : sun8i Revision : 0000 Serial : 2925032c2044fffff18f 系统调用 #include <sched.h> //

Python 3.6.0: 'os' module does not have 'sched_getaffinity' method

落花浮王杯 提交于 2019-12-12 13:15:10
问题 I am trying to check the number of cores my script is using with 'os.sched_getaffinity' method as suggested in Why does multiprocessing use only a single core after I import numpy?. But when I run import os os.sched_getaffinity(0) I get AttributeError Traceback (most recent call last) <ipython-input-1-895d9c252fd1> in <module>() 1 import os ----> 2 os.sched_getaffinity(0) AttributeError: module 'os' has no attribute 'sched_getaffinity' What is going wrong here? Other standard methods from the

Ada program works in Linux but not in GPS Windows 10

不羁岁月 提交于 2019-12-12 12:07:30
问题 Thanks in advance for any help. I am currently doing some beginner work on ada programming and I have installed GNAT Programming Studio (GPS) from http://libre.adacore.com/download/configurations# I have Windows 10 64-bits. I was given the following code at school: pragma Task_Dispatching_Policy(FIFO_Within_Priorities); with Ada.Text_IO; use Ada.Text_IO; with Ada.Real_Time; use Ada.Real_Time; procedure PeriodicTasks is Start : Time; package Duration_IO is new Ada.Text_IO.Fixed_IO(Duration);