3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

tasksetとは

Last updated at Posted at 2019-08-19

tasksetとは

プロセスはロードバランサ機能によってシステムの負荷に応じて複数の論理CPUをまたいで実行することがあるらしい.
そこで, プログラムを1つの論理CPU上で実行させるためのコマンドとして, taskset と呼ばれるものが用意されている.

つかいかた

tasksetコマンドは -c オプションで指定した論理CPU上で, 引数に与えたプログラムを実行する.
以下の場合, 論理CPU 0上で a.out というプログラムが走ることになる.

$ taskset -c 0 ./a.out

CPUの情報を確認する

tasksetコマンドを使う前に, そもそもマシン上のCPUの情報を確認しておきたいというケースがある.
そういったときに使えるコマンドをまとめた.

物理CPUの確認

以下の実行結果の場合, 物理CPUは1つだと分かる(physical idが全て同一のため).

$ cat /proc/cpuinfo | grep 'physical id'
physical id	: 0
physical id	: 0

論理CPUの確認

以下の実行結果の場合, 論理CPUは2つだと分かる.

$ cat /proc/cpuinfo | grep processor
processor	: 0
processor	: 1

コアの確認

以下の実行結果の場合, それぞれの論理CPUはコアを2つ持っていると分かる.

$ cat /proc/cpuinfo | grep 'cpu cores'
cpu cores	: 2
cpu cores	: 2

余談

ちなみにVirtualBoxでは, 設定 > システム > プロセッサー > プロセッサー数 から論理CPUの数をいじることができる.

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?