18禁网站免费,成年人黄色视频网站,熟妇高潮一区二区在线播放,国产精品高潮呻吟AV

學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Ubuntu怎么綁定CPU進(jìn)程

Ubuntu怎么綁定CPU進(jìn)程

時(shí)間: 春健736 分享

Ubuntu怎么綁定CPU進(jìn)程

  有時(shí)候?yàn)榱烁玫夭僮鳈C(jī)器, 需要將某個(gè)進(jìn)程綁定到具體的CPU上去,那么Ubuntu怎么綁定CPU進(jìn)程呢?就讓學(xué)習(xí)啦小編來告訴大家Ubuntu綁定CPU進(jìn)程的方法吧,希望對(duì)大家有所幫助。

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

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

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

  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號(hào)為26502)永久的分配給5號(hào)CPU核(CPU核號(hào)從0開始計(jì)算,因此序號(hào)4指的是5號(hào)CPU核)

  # taskset -cp 5 26531

  pid 26531‘s current affinity list: 0-7

  pid 26531’s new affinity list: 5

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

  隨著CPU核的多個(gè)化,這樣的綁定方法也是一樣的,無論綁定哪個(gè)CPU核都能啟動(dòng)同樣的效果,相信大家都追求運(yùn)行的高速度,趕快來學(xué)習(xí)綁定CPU進(jìn)程的方法吧!

看過“Ubuntu怎么綁定CPU進(jìn)程”的人還看了:

1.win10怎么安裝ubuntu

2.怎么在Ubuntu下搭建服務(wù)器

3.怎么安裝Ubuntu操作系統(tǒng)

4.Ubuntu下刪除模擬器失敗怎么解決

5.Ubuntu 14.04怎么安裝java

6.Ubuntu怎么安裝PlayOnLinux

1095286