• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

              牽著老婆滿街逛

              嚴(yán)以律己,寬以待人. 三思而后行.
              GMail/GTalk: yanglinbo#google.com;
              MSN/Email: tx7do#yahoo.com.cn;
              QQ: 3 0 3 3 9 6 9 2 0 .

              GNU CPU-Affinity

              轉(zhuǎn)載自:http://www.gnu.org/s/libc/manual/html_node/CPU-Affinity.html

              22.3.5 Limiting execution to certain CPUs

              On a multi-processor system the operating system usually distributes the different processes which are runnable on all available CPUs in a way which allows the system to work most efficiently. Which processes and threads run can be to some extend be control with the scheduling functionality described in the last sections. But which CPU finally executes which process or thread is not covered.

              There are a number of reasons why a program might want to have control over this aspect of the system as well:

              • One thread or process is responsible for absolutely critical work which under no circumstances must be interrupted or hindered from making process by other process or threads using CPU resources. In this case the special process would be confined to a CPU which no other process or thread is allowed to use.
              • The access to certain resources (RAM, I/O ports) has different costs from different CPUs. This is the case in NUMA (Non-Uniform Memory Architecture) machines. Preferably memory should be accessed locally but this requirement is usually not visible to the scheduler. Therefore forcing a process or thread to the CPUs which have local access to the mostly used memory helps to significantly boost the performance.
              • In controlled runtimes resource allocation and book-keeping work (for instance garbage collection) is performance local to processors. This can help to reduce locking costs if the resources do not have to be protected from concurrent accesses from different processors.

              The POSIX standard up to this date is of not much help to solve this problem. The Linux kernel provides a set of interfaces to allow specifying affinity sets for a process. The scheduler will schedule the thread or process on CPUs specified by the affinity masks. The interfaces which the GNU C library define follow to some extend the Linux kernel interface.

              — Data Type: cpu_set_t

              This data set is a bitset where each bit represents a CPU. How the system's CPUs are mapped to bits in the bitset is system dependent. The data type has a fixed size; in the unlikely case that the number of bits are not sufficient to describe the CPUs of the system a different interface has to be used.

              This type is a GNU extension and is defined in sched.h.

              To manipulate the bitset, to set and reset bits, a number of macros is defined. Some of the macros take a CPU number as a parameter. Here it is important to never exceed the size of the bitset. The following macro specifies the number of bits in the cpu_set_t bitset.

              — Macro: int CPU_SETSIZE

              The value of this macro is the maximum number of CPUs which can be handled with a cpu_set_t object.

              The type cpu_set_t should be considered opaque; all manipulation should happen via the next four macros.

              — Macro: void CPU_ZERO (cpu_set_t *set)

              This macro initializes the CPU set set to be the empty set.

              This macro is a GNU extension and is defined in sched.h.

              — Macro: void CPU_SET (int cpu, cpu_set_t *set)

              This macro adds cpu to the CPU set set.

              The cpu parameter must not have side effects since it is evaluated more than once.

              This macro is a GNU extension and is defined in sched.h.

              — Macro: void CPU_CLR (int cpu, cpu_set_t *set)

              This macro removes cpu from the CPU set set.

              The cpu parameter must not have side effects since it is evaluated more than once.

              This macro is a GNU extension and is defined in sched.h.

              — Macro: int CPU_ISSET (int cpu, const cpu_set_t *set)

              This macro returns a nonzero value (true) if cpu is a member of the CPU set set, and zero (false) otherwise.

              The cpu parameter must not have side effects since it is evaluated more than once.

              This macro is a GNU extension and is defined in sched.h.

              CPU bitsets can be constructed from scratch or the currently installed affinity mask can be retrieved from the system.

              — Function: int sched_getaffinity (pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)

              This functions stores the CPU affinity mask for the process or thread with the ID pid in the cpusetsize bytes long bitmap pointed to by cpuset. If successful, the function always initializes all bits in the cpu_set_t object and returns zero.

              If pid does not correspond to a process or thread on the system the or the function fails for some other reason, it returns -1 and errno is set to represent the error condition.

              ESRCH
              No process or thread with the given ID found. 
              EFAULT
              The pointer cpuset is does not point to a valid object.

              This function is a GNU extension and is declared in sched.h.

              Note that it is not portably possible to use this information to retrieve the information for different POSIX threads. A separate interface must be provided for that.

              — Function: int sched_setaffinity (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)

              This function installs the cpusetsize bytes long affinity mask pointed to by cpuset for the process or thread with the ID pid. If successful the function returns zero and the scheduler will in future take the affinity information into account.

              If the function fails it will return -1 and errno is set to the error code:

              ESRCH
              No process or thread with the given ID found. 
              EFAULT
              The pointer cpuset is does not point to a valid object. 
              EINVAL
              The bitset is not valid. This might mean that the affinity set might not leave a processor for the process or thread to run on.

              This function is a GNU extension and is declared in sched.h.

              posted on 2010-10-31 15:55 楊粼波 閱讀(504) 評論(0)  編輯 收藏 引用


              只有注冊用戶登錄后才能發(fā)表評論。
              網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


              久久久久久无码Av成人影院| 国产精久久一区二区三区| 久久久久久国产a免费观看黄色大片| 93精91精品国产综合久久香蕉 | 国产激情久久久久影院老熟女| 91久久成人免费| 久久只这里是精品66| 久久无码人妻一区二区三区午夜 | 日本免费久久久久久久网站| 国产成人精品综合久久久| 久久精品国产男包| 久久er热视频在这里精品| 手机看片久久高清国产日韩| 久久久久人妻一区二区三区vr| 久久精品二区| 国产亚洲精品自在久久| 久久久久国产视频电影| 久久精品草草草| 国内精品人妻无码久久久影院| 欧美久久一区二区三区| 狠狠色丁香婷综合久久| 久久精品aⅴ无码中文字字幕不卡| 欧美久久综合性欧美| 久久99精品久久久久子伦| 狠狠色丁香久久婷婷综合蜜芽五月 | 久久国产精品成人影院| 久久99精品国产麻豆宅宅| 人妻精品久久久久中文字幕| 青青国产成人久久91网| 国产99精品久久| 日韩精品国产自在久久现线拍 | 国产精品久久久久蜜芽| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久笫一福利免费导航| 一个色综合久久| 天天影视色香欲综合久久| 日韩欧美亚洲综合久久影院Ds | 久久香蕉国产线看观看99| 久久精品国产亚洲麻豆| 久久国产精品一区二区| 国内精品久久久久久不卡影院|