Movatterモバイル変換


[0]ホーム

URL:


Skip Navigation Links
Exit Print View
Link to oracle.comman pages section 5: Standards, Environments, and Macros    Oracle Solaris 11 Information Library
Oracle Technology Network
Library
PDF
Print View
Feedback
search filter icon
search icon
 Search Scope:

Document Information

Preface

Introduction

Standards, Environments, and Macros

acl(5)

ad(5)

advance(5)

adv_cap_1000fdx(5)

adv_cap_1000hdx(5)

adv_cap_100fdx(5)

adv_cap_100hdx(5)

adv_cap_10fdx(5)

adv_cap_10hdx(5)

adv_cap_asym_pause(5)

adv_cap_autoneg(5)

adv_cap_pause(5)

adv_rem_fault(5)

ANSI(5)

architecture(5)

ascii(5)

attributes(5)

audit_binfile(5)

audit_flags(5)

audit_remote(5)

audit_syslog(5)

availability(5)

brands(5)

C++(5)

C(5)

cancellation(5)

cap_1000fdx(5)

cap_1000hdx(5)

cap_100fdx(5)

cap_100hdx(5)

cap_10fdx(5)

cap_10hdx(5)

cap_asym_pause(5)

cap_autoneg(5)

cap_pause(5)

cap_rem_fault(5)

charmap(5)

compile(5)

condition(5)

crypt_bsdbf(5)

crypt_bsdmd5(5)

crypt_sha256(5)

crypt_sha512(5)

crypt_sunmd5(5)

crypt_unix(5)

CSI(5)

device_clean(5)

dhcp(5)

dhcp_modules(5)

environ(5)

eqnchar(5)

extendedFILE(5)

extensions(5)

filesystem(5)

fmri(5)

fnmatch(5)

formats(5)

fsattr(5)

grub(5)

gss_auth_rules(5)

hal(5)

iconv_1250(5)

iconv_1251(5)

iconv(5)

iconv_646(5)

iconv_852(5)

iconv_8859-1(5)

iconv_8859-2(5)

iconv_8859-5(5)

iconv_dhn(5)

iconv_koi8-r(5)

iconv_mac_cyr(5)

iconv_maz(5)

iconv_pc_cyr(5)

iconv_unicode(5)

ieee802.11(5)

ieee802.3(5)

ipfilter(5)

ipkg(5)

isalist(5)

ISO(5)

kerberos(5)

krb5_auth_rules(5)

krb5envvar(5)

KSSL(5)

kssl(5)

labels(5)

largefile(5)

ldap(5)

lf64(5)

lfcompile(5)

lfcompile64(5)

link_duplex(5)

link_rx_pause(5)

link_tx_pause(5)

link_up(5)

locale(5)

locale_alias(5)

lp_cap_1000fdx(5)

lp_cap_1000hdx(5)

lp_cap_100fdx(5)

lp_cap_100hdx(5)

lp_cap_10fdx(5)

lp_cap_10hdx(5)

lp_cap_asym_pause(5)

lp_cap_autoneg(5)

lp_cap_pause(5)

lp_rem_fault(5)

man(5)

mansun(5)

me(5)

mech_spnego(5)

mm(5)

ms(5)

MT-Level(5)

mutex(5)

MWAC(5)

mwac(5)

nfssec(5)

NIS+(5)

NIS(5)

nis(5)

nwam(5)

openssl(5)

pam_allow(5)

pam_authtok_check(5)

pam_authtok_get(5)

pam_authtok_store(5)

pam_deny(5)

pam_dhkeys(5)

pam_dial_auth(5)

pam_krb5(5)

pam_krb5_migrate(5)

pam_ldap(5)

pam_list(5)

pam_passwd_auth(5)

pam_pkcs11(5)

pam_rhosts_auth(5)

pam_roles(5)

pam_sample(5)

pam_smbfs_login(5)

pam_smb_passwd(5)

pam_tsol_account(5)

pam_unix_account(5)

pam_unix_auth(5)

pam_unix_cred(5)

pam_unix_session(5)

pam_zfs_key(5)

pkcs11_kernel(5)

pkcs11_kms(5)

pkcs11_softtoken(5)

pkcs11_tpm(5)

POSIX.1(5)

POSIX.2(5)

POSIX(5)

privileges(5)

prof(5)

pthreads(5)

RBAC(5)

rbac(5)

regex(5)

regexp(5)

resource_controls(5)

sgml(5)

smf(5)

smf_bootstrap(5)

smf_method(5)

smf_restarter(5)

smf_security(5)

smf_template(5)

solaris10(5)

solaris(5)

solbook(5)

stability(5)

standard(5)

standards(5)

step(5)

sticky(5)

SUS(5)

SUSv2(5)

SUSv3(5)

SVID3(5)

SVID(5)

tecla(5)

teclarc(5)

term(5)

threads(5)

trusted_extensions(5)

vgrindefs(5)

wbem(5)

xcvr_addr(5)

xcvr_id(5)

xcvr_inuse(5)

XNS4(5)

XNS(5)

XNS5(5)

XPG3(5)

XPG4(5)

XPG4v2(5)

XPG(5)

zones(5)

threads

, pthreads

- POSIX pthreads and Solaris threads concepts

Synopsis

POSIX

cc –mt [flag... ]file... [ -lrtlibrary... ]
#include <pthread.h>

Solaris

cc –mt [flag... ]file... [library... ]
#include <sched.h>
#include <thread.h>

Description

POSIX and Solaris threads each have their own implementation withinlibc(3LIB). Bothimplementations are interoperable, their functionality similar, and can be used within the sameapplication. Only POSIX threads are guaranteed to be fully portable to otherPOSIX-compliant environments. POSIX and Solaris threads require different source, include files andlinking libraries. SeeSYNOPSIS.

Similarities

Most of the POSIX and Solaris threading functions have counterparts with eachother. POSIX function names, with the exception of the semaphore names, havea “pthread” prefix. Function names for similar POSIX and Solaris functions havesimilar endings. Typically, similar POSIX and Solaris functions have the same number anduse of arguments.

Differences

POSIX pthreads and Solaris threads differ in the following ways:

Function Comparison

The following table compares the POSIX pthreads and Solaris threads functions. Whena comparable interface is not available either in POSIX pthreads orSolaris threads, a hyphen () appears in the column.

Functions Related to Creation

POSIX
Solaris
pthread_create()
thr_create()
pthread_attr_init()
pthread_attr_setdetachstate()
pthread_attr_getdetachstate()
pthread_attr_setinheritsched()
pthread_attr_getinheritsched()
pthread_attr_setschedparam()
pthread_attr_getschedparam()
pthread_attr_setschedpolicy()
pthread_attr_getschedpolicy()
pthread_attr_setscope()
pthread_attr_getscope()
pthread_attr_setstackaddr()
pthread_attr_getstackaddr()
pthread_attr_setstacksize()
pthread_attr_getstacksize()
pthread_attr_getguardsize()
pthread_attr_setguardsize()
pthread_attr_destroy()
thr_min_stack()

Functions Related to Exit

POSIX
Solaris
pthread_exit()
thr_exit()
pthread_join()
thr_join()
pthread_detach()

Functions Related to Thread Specific Data

POSIX
Solaris
pthread_key_create()
thr_keycreate()
pthread_setspecific()
thr_setspecific()
pthread_getspecific()
thr_getspecific()
pthread_key_delete()

Functions Related to Signals

POSIX
Solaris
pthread_sigmask()
thr_sigsetmask()
pthread_kill()
thr_kill()

Functions Related to IDs

POSIX
Solaris
pthread_self()
thr_self()
pthread_equal()
thr_main()

Functions Related to Scheduling

POSIX
Solaris
thr_yield()
thr_suspend()
thr_continue()
pthread_setconcurrency()
thr_setconcurrency()
pthread_getconcurrency()
thr_getconcurrency()
pthread_setschedparam()
thr_setprio()
pthread_setschedprio()
thr_setprio()
pthread_getschedparam()
thr_getprio()

Functions Related to Cancellation

POSIX
Solaris
pthread_cancel()
pthread_setcancelstate()
pthread_setcanceltype()
pthread_testcancel()
pthread_cleanup_pop()
pthread_cleanup_push()

Functions Related to Mutexes

POSIX
Solaris
pthread_mutex_init()
mutex_init()
pthread_mutexattr_init()
pthread_mutexattr_setpshared()
pthread_mutexattr_getpshared()
pthread_mutexattr_setprotocol()
pthread_mutexattr_getprotocol()
pthread_mutexattr_setprioceiling()
pthread_mutexattr_getprioceiling()
pthread_mutexattr_settype()
pthread_mutexattr_gettype()
pthread_mutexattr_setrobust()
pthread_mutexattr_getrobust()
pthread_mutexattr_destroy()
pthread_mutex_setprioceiling()
pthread_mutex_getprioceiling()
pthread_mutex_lock()
mutex_lock()
pthread_mutex_trylock()
mutex_trylock()
pthread_mutex_unlock()
mutex_unlock()
pthread_mutex_destroy()
mutex_destroy()

Functions Related to Condition Variables

POSIX
Solaris
pthread_cond_init()
cond_init()
pthread_condattr_init()
pthread_condattr_setpshared()
pthread_condattr_getpshared()
pthread_condattr_destroy()
pthread_cond_wait()
cond_wait()
pthread_cond_timedwait()
cond_timedwait()
pthread_cond_signal()
cond_signal()
pthread_cond_broadcast()
cond_broadcast()
pthread_cond_destroy()
cond_destroy()

Functions Related to Reader/Writer Locking

POSIX
Solaris
pthread_rwlock_init()
rwlock_init()
pthread_rwlock_rdlock()
rw_rdlock()
pthread_rwlock_tryrdlock()
rw_tryrdlock()
pthread_rwlock_wrlock()
rw_wrlock()
pthread_rwlock_trywrlock()
rw_trywrlock()
pthread_rwlock_unlock()
rw_unlock()
pthread_rwlock_destroy()
rwlock_destroy()
pthread_rwlockattr_init()
pthread_rwlockattr_destroy()
pthread_rwlockattr_getpshared()
pthread_rwlockattr_setpshared()

Functions Related to Semaphores

POSIX
Solaris
sem_init()
sema_init()
sem_open()
sem_close()
sem_wait()
sema_wait()
sem_trywait()
sema_trywait()
sem_post()
sema_post()
sem_getvalue()
sem_unlink()
sem_destroy()
sema_destroy()

Functions Related to fork( ) Clean Up

POSIX
Solaris
pthread_atfork()

Functions Related to Limits

POSIX
Solaris
pthread_once()

Functions Related to Debugging

POSIX
Solaris
thr_stksegment()

Locking

Synchronization

Multithreaded behavior is asynchronous, and therefore, optimized for concurrent and parallelprocessing. As threads, always from within the same process and sometimesfrom multiple processes, share global data with each other, they are notguaranteed exclusive access to the shared data at any point in time. Securingmutually exclusive access to shared data requires synchronization among the threads.Both POSIX and Solaris implement four synchronization mechanisms: mutexes, condition variables, reader/writerlocking (optimized frequent-read occasional-write mutex), and semaphores.

Synchronizing multiple threads diminishes their concurrency. The coarser the grain of synchronization,that is, the larger the block of code that is locked, thelesser the concurrency.

MTfork()

If a threads program callsfork(2), it implicitly callsfork1(2), which replicatesonly the calling thread. Should there be any outstanding mutexes throughout theprocess, the application should callpthread_atfork(3C) to wait for and acquire thosemutexes prior to callingfork().

SCHEDULING

POSIX Threads

Solaris supports the following three POSIX scheduling policies:

SCHED_OTHER

Traditional Timesharing scheduling policy. It is based on the timesharing (TS) scheduling class.

SCHED_FIFO

First-In-First-Out scheduling policy. Threads scheduled to this policy, if not preempted by a higher priority, will proceed until completion. Such threads are in real-time (RT) scheduling class. The calling process must have the {PRIV_PROC_PRIOCNTL} privilege asserted in its effective set.

SCHED_RR

Round-Robin scheduling policy. Threads scheduled to this policy, if not preempted by a higher priority, will execute for a time period determined by the system. Such threads are in real-time (RT) scheduling class and the calling process must have the {PRIV_PROC_PRIOCNTL} privilege asserted in its effective set.

In addition to the POSIX-specified scheduling policies above, Solaris also supports thesescheduling policies:

SCHED_IA

Threads are scheduled according to the Inter-Active Class (IA) policy as described inpriocntl(2).

SCHED_FSS

Threads are scheduled according to the Fair-Share Class (FSS) policy as described inpriocntl(2).

SCHED_FX

Threads are scheduled according to the Fixed-Priority Class (FX) policy as described inpriocntl(2).

Solaris Threads

Only scheduling policy supported isSCHED_OTHER, which is timesharing, based on theTS scheduling class.

Errors

In a multithreaded application,EINTR can be returned from blocking system callswhen another thread callsforkall(2).

Usage

-mt compiler option

The-mt compiler option compiles and links for multithreaded code. It compilessource files with -D_REENTRANT and augments the set of support libraries properly.

Attributes

Seeattributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
MT-Level
MT-Safe, Fork 1-Safe

See Also

crle(1),fork(2),priocntl(2),libpthread(3LIB),librt(3LIB),libthread(3LIB),pthread_atfork(3C),pthread_create(3C),attributes(5),privileges(5),standards(5)

Linker and Libraries Guide

Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices
PreviousNext

[8]ページ先頭

©2009-2025 Movatter.jp