disk$0、disk$1などと名付けられたスレッドは何ですか?

disk$0、disk$1などと名付けられたスレッドは何ですか?

私はUbuntu 20.04 LTSを使用しています。カーネルバージョンは5.4.0-42です。

以下はサンプルプログラムです:

// mre.c
// Compile with: cc -o mre mre.c -lSDL2
#include <stdio.h>
#include <SDL2/SDL.h>
int main(void)
{
    SDL_Init(SDL_INIT_VIDEO); // Doesn't work without SDL_INIT_VIDEO
    getchar();
}

./mreスレッド名がopenの実行中のプログラムを見ると、htop次の4つのスレッドがあることがわかります。

  • mre:disk$3
  • mre:disk$2
  • mre:disk$1
  • mre:disk$0

/usr/libexec/ibus-x11同様の名前を持つスレッドは次のとおりです。

  • ibus-x1:disk$3
  • ibus-x1:disk$2
  • ibus-x1:disk$1
  • ibus-x1:disk$0

多くのプログラムにはこれらの機能はありません。 (特定のグラフィックインターフェイスを使用していない可能性があります。)

これらのスレッドには常に4つ(マイコンピュータには4つのコアがあります)があり、降順で一覧表示されます。/usr/lib/xorg/Xorgこれらのスレッドは8つで、各数字0〜3に対して2つあります。それらは何のために使用されますか?

ベストアンサー1

このスレッドは次の目的で使用されます。メサディスクキャッシュ:

   util_queue_init(&cache->cache_queue, "disk$", 32, 4,
                   UTIL_QUEUE_INIT_RESIZE_IF_FULL |
                   UTIL_QUEUE_INIT_USE_MINIMUM_PRIORITY |
                   UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY);

https://sources.debian.org/src/mesa/22.0.3-1/src/util/disk_cache.c/?hl=174#L174

その後、内部util_queue_init()

   /* Form the thread name from process_name and name, limited to 13
    * characters. Characters 14-15 are reserved for the thread number.
    * Character 16 should be 0. Final form: "process:name12"
    *
    * If name is too long, it's truncated. If any space is left, the process
    * name fills it.
    */

https://sources.debian.org/src/mesa/22.0.3-1/src/util/u_queue.c/?hl=405#L414-L420

したがって、何らかの方法でこのデスクトップコードを呼び出すすべてのGUIプロセスは、たとえば私のf33デスクトップシステムでこれらの追加のスレッドを生成します。

    pid     tid            comm cls
   1942    1989  gnome-s:disk$0 BAT 
   1942    1990  gnome-s:disk$1 BAT 
   1942    1991  gnome-s:disk$2 BAT 
   1942    1992  gnome-s:disk$3 BAT 
   2041    2237  Xwaylan:disk$0 BAT 
   2041    2238  Xwaylan:disk$1 BAT 
   2041    2239  Xwaylan:disk$2 BAT 
   2041    2240  Xwaylan:disk$3 BAT 
   2041    2259  Xwaylan:disk$0 BAT 
   2041    2260  Xwaylan:disk$1 BAT 
   2041    2261  Xwaylan:disk$2 BAT 
   2041    2262  Xwaylan:disk$3 BAT 
   2292    2325  gsd-xse:disk$0 BAT 
   2292    2326  gsd-xse:disk$1 BAT 
   2292    2327  gsd-xse:disk$2 BAT 
   2292    2328  gsd-xse:disk$3 BAT 
   2307    2344  ibus-x1:disk$0 BAT 
   2307    2345  ibus-x1:disk$1 BAT 
   2307    2346  ibus-x1:disk$2 BAT 
   2307    2347  ibus-x1:disk$3 BAT 
   2464    2578  firefox:disk$0 BAT 
   2464    2579  firefox:disk$1 BAT 
   2464    2580  firefox:disk$2 BAT 
   2464    2581  firefox:disk$3 BAT 
   2756    2785  firefox:disk$0 BAT 
   2756    2786  firefox:disk$1 BAT 
   2756    2787  firefox:disk$2 BAT 
   2756    2788  firefox:disk$3 BAT 
   2806    2841  firefox:disk$0 BAT 
   2806    2842  firefox:disk$1 BAT 
   2806    2843  firefox:disk$2 BAT 
   2806    2844  firefox:disk$3 BAT 
   2919    3078  firefox:disk$0 BAT 
   2919    3079  firefox:disk$1 BAT 
   2919    3080  firefox:disk$2 BAT 
   2919    3081  firefox:disk$3 BAT 
   3346    3367  firefox:disk$0 BAT 
   3346    3368  firefox:disk$1 BAT 
   3346    3369  firefox:disk$2 BAT 
   3346    3370  firefox:disk$3 BAT 
   3408    3426  firefox:disk$0 BAT 
   3408    3427  firefox:disk$1 BAT 
   3408    3428  firefox:disk$2 BAT 
   3408    3429  firefox:disk$3 BAT 
   5794    5825  firefox:disk$0 BAT 
   5794    5826  firefox:disk$1 BAT 
   5794    5827  firefox:disk$2 BAT 
   5794    5828  firefox:disk$3 BAT 
   6345    6364  firefox:disk$0 BAT 
   6345    6365  firefox:disk$1 BAT 
   6345    6366  firefox:disk$2 BAT 
   6345    6367  firefox:disk$3 BAT 
   9502    9525  firefox:disk$0 BAT 
   9502    9526  firefox:disk$1 BAT 
   9502    9527  firefox:disk$2 BAT 
   9502    9528  firefox:disk$3 BAT 
  22548   22565  firefox:disk$0 BAT 
  22548   22566  firefox:disk$1 BAT 
  22548   22567  firefox:disk$2 BAT 
  22548   22568  firefox:disk$3 BAT 
  33788   33807      vlc:disk$0 BAT 
  33788   33808      vlc:disk$1 BAT 
  33788   33809      vlc:disk$2 BAT 
  33788   33810      vlc:disk$3 BAT 
  48178   74574  kwallet:disk$0 BAT 
  48178   74575  kwallet:disk$1 BAT 
  48178   74576  kwallet:disk$2 BAT 
  48178   74577  kwallet:disk$3 BAT 
  60824   60830  chromiu:disk$0 BAT 
  60824   60831  chromiu:disk$1 BAT 
  60824   60832  chromiu:disk$2 BAT 
  60824   60833  chromiu:disk$3 BAT 
  69502   69519  firefox:disk$0 BAT 
  69502   69520  firefox:disk$1 BAT 
  69502   69521  firefox:disk$2 BAT 
  69502   69522  firefox:disk$3 BAT

おすすめ記事