人妻丰满熟妇无码区乱com|久久婷婷午夜精品二区|一道本国产不卡视频|国产孕妇故爱A级高清片免费看

<tbody id="geoqw"></tbody>
  • <center id="geoqw"></center>
  • <menu id="geoqw"></menu>
  • <center id="geoqw"></center>
    
    <menu id="geoqw"></menu>
  • 在Ubuntu中綁定CPU進(jìn)程的方法

    時(shí)間:2021-02-18 09:09:44 硬件知識 我要投稿

    在Ubuntu中綁定CPU進(jìn)程的方法

      Linux進(jìn)程包括核心進(jìn)程和普通進(jìn)程,把普通進(jìn)程綁定到Linux系統(tǒng)CPU核中運(yùn)行,那么普通進(jìn)程就成了核心進(jìn)程。本文就以Ubuntu為例子來介紹一下,在Ubuntu中怎么綁定CPU進(jìn)程。

      taskset -cp 《CPU ID | CPU IDs》 《Process ID》

      下面用一個(gè)簡單的例子來說明怎樣做到。

      1. CPU利用率達(dá)100%的樣例代碼:

      class Test {

      public static void main(String args[]) {

      int i = 0;

      while (true) {

      i++;

      }

      }

      }

      2. 編譯并運(yùn)行上面的樣例代碼

      # javac Test.java

      # java Test &

      [1] 26531

      3. 使用htop命令查看CPU的利用率

      如果未安裝htop工具,執(zhí)行下面的命令:

      # apt-get install htop

      Reading package lists... Done

      Building dependency tree

      Reading state information... Done

      The following NEW packages will be installed:

      htop

      0 upgraded, 1 newly installed, 0 to remove and 41 not upgraded.

      Need to get 66.9 kB of archives.

      After this operation, 183 kB of additional disk space will be used.

      Get:1 http://mirrors.163.com/ubuntu/ precise/universe htop amd64 1.0.1-1 [66.9 kB]

      Fetched 66.9 kB in 0s (163 kB/s)

      Selecting previously unselected package htop.

      (Reading database ... 57100 files and directories currently installed.)

      Unpacking htop (from .../htop_1.0.1-1_amd64.deb)...

      Processing triggers for man-db ...

      Setting up htop (1.0.1-1)...

      安裝完成后,執(zhí)行命令:

      # htop

      上面的視圖可以看到,CPU2的利用率達(dá)到100%,且這個(gè)進(jìn)程有可能被分配到其它CPU核上運(yùn)行,這個(gè)分配是不定的。

      4. 進(jìn)程綁定CPU核

      運(yùn)行以下命令,把此Java進(jìn)程(進(jìn)程ID號為26502)永久的分配給5號CPU核(CPU核號從0開始計(jì)算,因此序號4指的`是5號CPU核)

      # taskset -cp 5 26531

      pid 26531‘s current affinity list: 0-7

      pid 26531’s new affinity list: 5

      從上面的視圖中可以看到6號CPU核的利用率為100%。

      以上就是在Ubuntu中怎么綁定CPU進(jìn)程的介紹了,當(dāng)然有些CPU核可能不只一個(gè),不過不管綁定到哪個(gè)核效果都是一樣的。

    【在Ubuntu中綁定CPU進(jìn)程的方法】相關(guān)文章:

    在Linux系統(tǒng)中限制CPU占用率的方法03-10

    doscanexe的進(jìn)程占用了大量的CPU和內(nèi)存的解決方法03-09

    CPU超頻方法03-13

    Win8.1系統(tǒng)taskhost.exe進(jìn)程占用CPU非常高的解決方法03-14

    讓cpu降溫的方法04-03

    解決CPU故障的方法03-14

    識別真假CPU的方法03-13

    CPU優(yōu)化方法介紹03-12

    電腦cpu更換方法03-11