Home > pthread setaffinity np error > pthread_setaffinity_np error 22

Pthread_setaffinity_np Error 22

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and pthread_setaffinity_np vs sched_setaffinity policies of this site About Us Learn more about Stack Overflow the pthread_setaffinity_np example company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags

Cpu_set_t

Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only

Cpu_zero

takes a minute: Sign up Pthread_setaffinity_np invalid argument up vote 2 down vote favorite 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(" thread no. is %d \n",a); CPU_ZERO(&mask); a =a/2 sched_setaffinity example + 1; CPU_SET(a,&mask); c=pthread_self(); s=pthread_setaffinity_np(c,sizeof(cpu_set_t), &mask); if (s!=0) handle_error_en(s,"pthread_setaffinity_np"); The thread affinity is not getting changed. Where am I going wrong? c++ c pthreads setthreadaffinitymask share|improve this question edited Jan 20 '12 at 12:49 BЈовић 36.4k23100176 asked Jan 16 '12 at 21:50 akhil28288 10710 You can replace the entire switch statement with CPU_SET((a/2+1), &mask);, by the way. –Daniel Fischer Jan 16 '12 at 21:57 Ohh Thanks... :P –akhil28288 Jan 16 '12 at 21:59 Perhaps better, to be sure it's evaluated only once, a = a/2+1; CPU_SET(a, &mask);. –Daniel Fischer Jan 16 '12 at 22:05 1 You're passing the same int pointer to all the threads, which all dereference it some time later, after the int has changed. –bk1e Jan 17 '12 at 3:00 1 Also, maybe the function that created the threads returns before they read the int, and something else uses the same stack location. –bk1e Jan 17 '12 at 3:03 | show 3 more comments 1 Answer 1 active oldest votes up vote 1 down vote accepted I had misunderstood

int cpusetsize, const cpu_set_t *mask); int pthread_getaffinity_np(pthread_t tid, int cpusetsize, cpu_set_t *mask); Description pthread_setaffinity_np sets the CPU affinity mask of the thread whose ID is

Set Affinity Linux Example

tid to the value specified by mask. The argument cpusetsize is pthread_attr_setaffinity_np the length (in bytes) of the data pointed to by mask. Normally this argument would be specified pthread_attr_setaffinity_np example as sizeof(cpu_set_t). If the thread specified by tid is not currently running on one of the CPUs specified in mask, then that thread is migrated to one of http://stackoverflow.com/questions/8886778/pthread-setaffinity-np-invalid-argument the CPUs specified in mask. After a call to pthread_setaffinity_np, the set of CPUs on which the thread will actually run is the intersection of the set specified in the mask argument and the set of CPUs actually present on the system. pthread_getaffinity_np writes the affinity mask of the thread whose ID is tid into the cpu_set_t http://www.sourceware.org/pthreads-win32/manual/pthread_setaffinity_np.html structure pointed to by mask. The cpusetsize argument specifies the size (in bytes) of mask. Pthreads-w32 currently ignores the cpusetsize parameter for either function because cpu_set_t is a direct typeset to the Windows affinity vector type DWORD_PTR. Return Value On success, pthread_setaffinity_np and pthread_getaffinity_np return 0. On error, an error number is returned. Errors EFAULT A supplied memory address was invalid. EINVAL The affinity bit mask mask contains no processors that are currently physically on the system. EAGAIN The function did not succeed in changing or obtaining the CPU affinity for some undetermined reason. Try again. EPERM The calling process does not have appropriate privileges. ESRCH The thread whose ID is tid could not be found. Application Usage A thread's CPU affinity mask determines the set of CPUs on which it is eligible to run. On a multiprocessor system, setting the CPU affinity mask can be used to obtain performance benefits. For example, by dedicating one CPU to a particular thread (i.e., setting the affinity mask

LearningModern CodeNetworkingOpen SourceStorageToolsDeveloper TypeEmbedded SystemsGame DevMediaTechnical, Enterprise, HPCWebOSAll ToolsAndroid*HTML5Linux*OS X*Windows*ResourcesCode SamplesContact SupportDocumentationFree SoftwareIntel Registration CenterProduct ForumsSDKsResourcesPartner with IntelAcademic ProgramPartner SpotlightBlack Belt DeveloperDeveloper MeshInnovator ProgramSuccess StoriesLearnBlogBusiness TipsEventsVideosSupportContact SupportDeveloper EvangelistsFAQsForums Search form Search You are hereHome › Forums › Platform and Technology Discussion https://software.intel.com/en-us/forums/intel-many-integrated-core/topic/536182 › Intel® Many Integrated Core Architecture (Intel MIC Architecture) FacebookLinkedInTwitterDiggDeliciousGoogle Plus Core https://forums.xilinx.com/t5/Embedded-Processor-System-Design/Microblaze-pthread-setaffinity-np-and-sync-fetch-and-add-4/td-p/227225 pinning with pthread Core pinning with pthread Jun Hyun S. Fri, 11/21/2014 - 01:19 Hi all, I did some follow-up on my last topic https://software.intel.com/en-us/forums/topic/533886  Long story short, I'm trying to emulate SIMD behavior in MIC environment, and I actually decided to implement the offloaded segment in native code without pthread_setaffinity_np error OpenMP pragmas, which means I'm implementing thread pinning to individual cores with pthread_attr_setaffinity_np. The logic is all there from start to finish. Here's what I did: 1. I got the number of logical cores using sysconf (_SC_NPROCESSORS_ONLN), which returns 240 (a 60-core 5110P). 2. Based on the parameters [range of cores to utilize] and [number of active threads per core], I pin pthread_setaffinity_np error 22 the necessary number of threads (computed from another user parameter) to the respective cores using pthread_attr_setaffinity_np(). (I even did the rotate-by-one trick to make sure the pinning starts from the first thread of the first core, so when I say logical core 0, it does mean thread 0 of core 0) 3. Start infinite loop where spawned threads are in an infinite loop with synchronization per each iteration with the parent process using pthread_barrier_wait() The current problem lies in step 2. I've created a pool of 'pthread_attr_t's for each pinning to logical core (240 attr variables), and when I try to initialize them with pthread_attr_setaffinity_np(), it returns error code 22: Invalid argument. It is important to mention that it does not fail from the get go. The pthread_attr_setaffinity_np() call runs smoothly from logical core 0 to logical core 106, but it fails on initialization for logical core 107. The man page for pthread_attr_setaffinity_np() suggests that EINVAL is returned when the CPU set is out of range and the CONFIG_NR_CPUS is in charge of the range. Another search told me that the variable can

Internet Explorer 11, Safari. Thank you! Toggle navigation My Account Sign Out Sign In Language Toggle English Japanese Chinese Shopping Cart All Silicon Devices Boards and Kits Intellectual Property Support Documentation Knowledge Base Community Forums Partners Videos All Applications Products Developer Zone Support About All Silicon Devices Boards and Kits Intellectual Property Support Documentation Knowledge Base Community Forums Partners Videos All Embedded Processor System Design Go To Community Forums Xcell Daily Blog Technical Blog About Our Community Announcements Welcome & Join General Technical Discussion Programmable Devices UltraScale Architecture™ 7 Series FPGAs Virtex® Family FPGAs Spartan® Family FPGAs Xilinx Boards and Kits Configuration Design Tools Installation and Licensing Synthesis Simulation and Verification Implementation Design Entry Timing Analysis Vivado TCL Community HLS Design Methodologies and Advanced Tools SDAccel Design Tools - Others Embedded Systems Embedded Development Tools Embedded Processor System Design Embedded Linux Zynq All Programmable SoC SDSoC Development Environment OpenAMP Intellectual Property PCI Express Networking and Connectivity MIG DSP and Video BRAM/FIFO CommunityCategoryBoardUsers turn on suggestions Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type. Showing results for  Search instead for  Do you mean  Register · Sign In · Help Community Forums : Xilinx Products : Embedded Systems : Embedded Processor System Design : Microblaze: pthread_setaffinity_np and __sync_fetc... Reply Topic Options Subscribe to RSS Feed Mark Topic as New Mark Topic as Read Float this Topic to the Top Bookmark Subscribe Printer Friendly Page « Message Listing « Previous Topic Next Topic

 

Related content

pthread_setaffinity_np error

Pthread setaffinity np Error p size t cpusetsize const cpu set t cpuset int pthread getaffinity np pthread t thread size t cpusetsize cpu set t cpuset Compile and link with -pthread Description The pthread setaffinity np function sets the CPU affinity mask of the thread Pthread setaffinity np Vs Sched setaffinity thread to the CPU set pointed to by cpuset If cpu set t the call is successful and the thread is not currently running on one of the CPUs pthread setaffinity example in cpuset then it is migrated to one of those CPUs The pthread getaffinity np function