表 9-2 は、Solaris スレッドの関数と pthread の関数を比較対照したものです。なお、Solaris スレッドの関数と pthread の関数が本質的に同じものとして並記されている場合でも、その引数は異なっていることがあります。
pthread または Solaris スレッドの側に相当するインタフェースがない場合は、「-」が記入されています。pthread 欄の項目で「POSIX 1003.4」または「POSIX.4」が付記されているものは、POSIX 規格のリアルタイムの仕様の一部で pthread の一部ではありません。
表 9-2 Solaris スレッドと POSIX pthread の比較
Solaris スレッド (libthread) |
pthread (libpthread) |
---|---|
thr_create() |
pthread_create() |
thr_exit() |
pthread_exit() |
thr_join() |
pthread_join() |
thr_yield() |
sched_yield() POSIX.4 |
thr_self() |
pthread_self() |
thr_kill() |
pthread_kill() |
thr_sigsetmask() |
pthread_sigmask() |
thr_setprio() |
pthread_setschedparam() |
thr_getprio() |
pthread_getschedparam() |
thr_setconcurrency() |
pthread_setconcurrency() |
thr_getconcurrency() |
pthread_getconcurrency() |
thr_suspend() |
- |
thr_continue() |
- |
thr_keycreate() |
pthread_key_create() |
- |
pthread_key_delete() |
thr_setspecific() |
pthread_setspecific() |
thr_getspecific() |
pthread_getspecific() |
- |
pthread_once() |
- |
pthread_equal() |
- |
pthread_cancel() |
- |
pthread_testcancel() |
- |
pthread_cleanup_push() |
- |
pthread_cleanup_pop() |
- |
pthread_setcanceltype() |
- |
pthread_setcancelstate() |
mutex_lock() |
pthread_mutex_lock() |
mutex_unlock() |
pthread_mutex_unlock() |
mutex_trylock() |
pthread_mutex_trylock() |
mutex_init() |
pthread_mutex_init() |
mutex_destroy() |
pthread_mutex_destroy() |
cond_wait() |
pthread_cond_wait() |
cond_timedwait() |
pthread_cond_timedwait() |
cond_signal() |
pthread_cond_signal() |
cond_broadcast() |
pthread_cond_broadcast() |
cond_init() |
pthread_cond_init() |
cond_destroy() |
pthread_cond_destroy() |
rwlock_init() |
pthread_rwlock_init() |
rwlock_destroy() |
pthread_rwlock_destroy() |
rw_rdlock() |
pthread_rwlock_rdlock() |
rw_wrlock() |
pthread_rwlock_wrlock() |
rw_unlock() |
pthread_rwlock_unlock() |
rw_tryrdlock() |
pthread_rwlock_tryrdlock() |
rw_trywrlock() |
pthread_rwlock_trywrlock() |
- |
pthread_rwlockattr_init() |
- |
pthread_rwlockattr_destroy() |
- |
pthread_rwlockattr_getpshared() |
- |
pthread_rwlockattr_setpshared() |
sema_init() |
sem_init() POSIX 1003.4 |
sema_destroy() |
sem_destroy() POSIX 1003.4 |
sema_wait() |
sem_wait() POSIX 1003.4 |
sema_post() |
sem_post() POSIX 1003.4 |
sema_trywait() |
sem_trywait() POSIX 1003.4 |
fork1() |
fork() |
- |
pthread_atfork() |
fork() (複数スレッドコピー) |
- |
- |
pthread_mutexattr_init() |
- |
pthread_mutexattr_destroy() |
cond_init() の type() 引数 |
pthread_mutexattr_setpshared() |
- |
pthread_mutexattr_getpshared() |
- |
pthread_mutex_attr_settype() |
- |
pthread_mutex_attr_gettype() |
- |
pthread_condattr_init() |
- |
pthread_condattr_destroy() |
cond_init() の type() 引数 |
pthread_condattr_setpshared() |
- |
pthread_condattr_getpshared() |
- |
pthread_attr_init() |
- |
pthread_attr_destroy() |
thr_create() の THR_BOUND フラグ |
pthread_attr_setscope() |
- |
pthread_attr_getscope() |
- |
pthread_attr_setguardsize() |
- |
pthread_attr_getguardsize() |
thr_create() の stack_size() 引数 |
pthread_attr_setstacksize() |
- |
pthread_attr_getstacksize() |
thr_create() の stack_addr() 引数 |
pthread_attr_setstackaddr() |
- |
pthread_attr_getstackaddr() |
thr_create() の THR_DETACH フラグ |
pthread_attr_setdetachstate() |
- |
pthread_attr_getdetachstate() |
- |
pthread_attr_setschedparam() |
- |
pthread_attr_getschedparam() |
- |
pthread_attr_setinheritsched() |
- |
pthread_attr_getinheritsched() |
- |
pthread_attr_setsschedpolicy() |
- |
pthread_attr_getschedpolicy() |
この章で説明する Solaris スレッドの関数を使用するには、リンクで Solaris スレッドライブラリ (-lthread) を指定しなければなりません。
Solaris スレッドと pthread で機能的にほとんど変わらない場合は (関数名と引数が違うとしても)、正しいインクルードファイルと関数プロトタイプを示した簡単な例を挙げているだけです。Solaris スレッドで戻り値が記述されていないものについては、『man pages section 3』から該当するページを探して、その関数の戻り値を調べてください。
Solaris 関連の関数の詳細は、pthread の関連マニュアルで類似した名前の関数を調べてください。
Solaris スレッドの関数で pthread にない機能をもつものについて、詳しく説明しています。