gettid

Section: System Calls (2)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

gettid - スレッドID を取得する  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#define _GNU_SOURCE
#include <unistd.h>

pid_t gettid(void);
 

説明

gettid() は呼び出し元のスレッド ID (TID) を返す。 シングルスレッドのプロセスでは、スレッド ID は (getpid(2) が返すプロセス ID (PID) と等しい。 マルチスレッドのプロセスでは、全てのスレッドは同じ PID を持つが、 それぞれのスレッドは一意な TID を持つ。 さらなる詳細は、 clone(2) の CLONE_THREAD についての議論を参照すること。  

返り値

成功の場合、呼び出し元のスレッドのスレッドID を返す。  

エラー

このコールは常に成功する。  

標準規格

Linux.  

歴史

Linux 2.4.11, glibc 2.30.  

注意

このシステムコールが返すスレッド ID は POSIX スレッド ID (pthread_self(3) が返す曖昧な値) と同じものではない。

In a new thread group created by a clone(2) call that does not specify the CLONE_THREAD flag (or, equivalently, a new process created by fork(2)), the new process is a thread group leader, and its thread group ID (the value returned by getpid(2)) is the same as its thread ID (the value returned by gettid()).  

関連項目

capget(2), clone(2), fcntl(2), fork(2), get_robust_list(2), getpid(2), ioprio_set(2), perf_event_open(2), sched_setaffinity(2), sched_setparam(2), sched_setscheduler(2), tgkill(2), timer_create(2)


 

Index

名前
ライブラリ
書式
説明
返り値
エラー
標準規格
歴史
注意
関連項目

This document was created by man2html, using the manual pages.