Results 1 to 7 of 7

Thread: How to set a pthread's affinity to a core instead of a processor

  1. #1
    Join Date
    Apr 2010
    Posts
    199

    How to set a pthread's affinity to a core instead of a processor

    I would similar to specify the CPU affinity of a scrupulous pthread. The entire the references I have encompassed and originate so far deal by means of setting the CPU affinity of a process (pid_t) not a thread (pthread_t). I tried a number of experiments transitory pthread_t's around and as predictable they fail. Am I trying to do impressive impossible. If not, be able to you send a pointer please. I desire to be familiar with for a specified thread, which processor it is working with on. I have my own reason to be familiar with that.

  2. #2
    Join Date
    May 2009
    Posts
    979

    Re: How to set a pthread's affinity to a core instead of a processor

    The interface to situation the affinity is as you have comprised almost certainly previously discovered. Passing 0 as the pid, and it determine to apply to the present thread merely, or have additional thread report their kernel pid by means of the Linux unambiguous call pid_t gettid(void); and pass that in as the pid. I am working with RedHat Enterprise 3 up 2 WS and tried using the pthread_attr_setaffinity_np call. I call the purpose and something occurs by means of the CPU load distribution. On the other hand, I do not encompass a tool to conclude what threads are where. Is there such a tool. In addition I noticed half the time when I identify what CPU to run on that CPU is not utilized viewing in 'top'.

  3. #3
    Join Date
    May 2009
    Posts
    857

    Re: How to set a pthread's affinity to a core instead of a processor

    The affinity mask is essentially a per-thread characteristic that be able to be adjusted autonomously for every of the threads in a thread group. The value returned from a call to gettid be able to be passed in the argument pid. Specifying pid as 0 determine to set the characteristic for the calling thread, and passing the value returned from a call to getpid determine to set the characteristic for the most important thread of the thread group. (If you are using the POSIX threads API, then utilize pthread_setaffinity_np as an alternative of sched_setaffinity.).

  4. #4
    Join Date
    Aug 2009
    Posts
    922

    Re: How to set a pthread's affinity to a core instead of a processor

    I tried affinity and got such responsibility set in errno (sched_getaffinity and sechd_setaffinity come the entire in excess of again. My apparatus is dual CPU Intel Xeon by means of Hyperthreading facilitated, working with Gentoo by means of Kernel 2.6.3-r1 might somebody give pleasure to tell me what does EFAULT mean is this circumstances. TW, these functions be able to get and set processes, additional than how to utilize them to set CPU affinity for threads.

  5. #5
    Join Date
    Aug 2009
    Posts
    652

    Re: How to set a pthread's affinity to a core instead of a processor

    That call by means of 3-d param as unacceptable is unsuitable for the kernel call. Of course, if your glibc has hold up or maintain for those calls, it might take care regarding it, providing temp changeable for system call additional than returning nothing to the user. Additional than that illustration works without that kind of direct hold up or maintain from glibc side, so unacceptable is not valid. In addition, if things are OK, sched_getaffinity() returns the real size of mask param (your len be supposed to be equal to that value) and == 4 (bytes) for 32-bit platforms.

  6. #6
    Join Date
    Apr 2008
    Posts
    3,339

    Re: How to set a pthread's affinity to a core instead of a processor

    The Processor affinity is an alteration of the native essential queue preparation algorithm in a symmetric multiprocessing operating system. Every task (be it procedure or thread) in the queue has a tag representative its preferred / kin processor. At distribution time, every task is distributed to its kin processor in predilection to additional. Processor affinity takes benefit of the fact that a number of remnants of a procedure might hang regarding in one processor's state (in particular, in its cache) from the most recent time the procedure ran, and so scheduling it to run on the similar processor the next time might result in the procedure running additional efficiently than if it were to run on another processor.

  7. #7
    Join Date
    May 2008
    Posts
    2,792

    Re: How to set a pthread's affinity to a core instead of a processor

    Actual preparation algorithm implementations differ in how powerfully they determine to adhere to processor affinity. Beneath convinced circumstances some implementations determine to permit a task to modify to an additional processor if this is deemed to be the majority efficient under the circumstances. An obvious illustration involves two processor-intensive tasks (A & B) having affinity to one processor at the same time as an additional processor lies unused. Numerous algorithms would shift task B to the second processor in organize to maximize processor utilization. Task B would then obtain affinity by means of the second processor at the same time as task A would continue to have affinity by means of the original processor.

Similar Threads

  1. Replies: 5
    Last Post: 26-03-2012, 03:26 PM
  2. Advise for changing from Dual Core processor to Quad Core processor
    By Non-$ensoi in forum Overclocking & Computer Modification
    Replies: 7
    Last Post: 25-03-2012, 04:09 PM
  3. Difference between AMD Triple Core processor and AMD Quad Core processor
    By JalB By in forum Motherboard Processor & RAM
    Replies: 5
    Last Post: 22-09-2011, 11:11 AM
  4. Replies: 4
    Last Post: 15-02-2011, 08:40 AM
  5. Intel Celeron Processor 900 vs. AMD Athlon II dual-core processor M320
    By Farhat007 in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 25-09-2010, 09:24 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,699,046.37685 seconds with 16 queries