1
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.

システムコールについて

1
Posted at

1. システムコールとは

  • ユーザーモードの各種プロセスがカーネル処理を呼び出す仕組みのこと
  • プロセスは通常ユーザーモードで実行している。カーネル処理を依頼するためにシステムコールを発行すると、CPUにおいて割込みと言うイベントが発生する。
  • システムコールの種類
  • プロセス生成・削除
  • メモリ確保・解放
  • プロセス間通信
  • ネットワーク操作
  • ファイルシステム操作
  • ファイル操作(デバイスアクセス)

2. straceコマンド

  • プロセスが呼び出すシステムコールをトレースし、その内容を表示することができる。

参考:strace コマンドの使い方をまとめてみた

3. sarコマンド

  • ユーザーモードとカーネルモードの割合を表示可能。
  • それぞれのカラムの意味
  • CPU : 各コアの意味。下記例では4コア搭載されている。ALLは全コアの平均
  • %user : ユーザが利用しているCPU使用率
  • %nice : nice値を変更しているプロセスのCPU使用率
  • %system : システムが利用しているCPU使用率。ここがカーネルモードの割合
  • %iowait : IO待ちしているCPU使用率
  • %steal : ゲストOSが割り当て要求をしたが、割り当ててもらえなかったCPU使用率
  • %idle : 待機中のCPU使用率
実行結果例
[root@m2aet101 ~]# sar -P ALL 1
Linux 3.10.0-229.el7.x86_64 (m2aet101)  2018年03月25日  _x86_64_        (4 CPU)

18時58分16秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
18時58分17秒     all      0.50      0.00      0.00      0.00      0.00     99.50
18時58分17秒       0      1.00      0.00      0.00      0.00      0.00     99.00
18時58分17秒       1      1.00      0.00      0.00      0.00      0.00     99.00
18時58分17秒       2      0.00      0.00      0.00      0.00      0.00    100.00
18時58分17秒       3      0.99      0.00      0.99      0.00      0.00     98.02

18時58分17秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
18時58分18秒     all      0.50      0.00      0.50      0.00      0.00     99.00
18時58分18秒       0      1.01      0.00      0.00      0.00      0.00     98.99
18時58分18秒       1      0.00      0.00      1.00      0.00      0.00     99.00
18時58分18秒       2      0.00      0.00      0.00      0.00      0.00    100.00
18時58分18秒       3      0.00      0.00      0.00      0.00      0.00    100.00
  • 一概には言えないが、%systemが数10%くらいになっている場合は不要なシステムコールを発行していたり、システム負荷が高すぎる可能性があるため注意。

  • straceに「-T」オプションを付けて実行することで各種システムコールの処理にかかった時間を表示可能。(単位:マイクロ秒)
    参考:Linux - sarコマンドについて

1
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
1
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?