threads(7) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

threads(7)

Standards, Environments, Macros, Character Sets, and miscellany
                                                                    threads(7)



NAME
       threads, pthreads - POSIX pthreads and Solaris threads concepts

SYNOPSIS
   POSIX
       #include <pthread.h>

   Solaris
       #include <sched.h>


       #include <thread.h>

DESCRIPTION
       POSIX  and  Solaris  threads  each have their own implementation within
       libc(3LIB). Both implementations are interoperable, their functionality
       similar,  and  can  be  used  within  the  same application. Only POSIX
       threads are guaranteed to be fully portable  to  other  POSIX-compliant
       environments.  POSIX  and Solaris threads require different source code
       and include files. See SYNOPSIS.

   Similarities
       Most of the POSIX and Solaris  threading  functions  have  counterparts
       with  each other. POSIX function names, with the exception of the sema‐
       phore names, have a "pthread" prefix. Function names for similar  POSIX
       and  Solaris  functions  have similar endings. Typically, similar POSIX
       and Solaris functions have the same number and use of arguments.

   Differences
       POSIX pthreads and Solaris threads differ in the following ways:

           o      POSIX threads are more portable.


           o      POSIX threads  establish  characteristics  for  each  thread
                  according to configurable attribute objects.


           o      POSIX pthreads implement thread cancellation.


           o      POSIX pthreads enforce scheduling algorithms.


           o      POSIX  pthreads  allow  for  clean-up  handlers  for fork(2)
                  calls.


           o      Solaris threads can be suspended and continued.


           o      Solaris threads implement daemon threads, for  whose  demise
                  the process does not wait.


FUNCTION COMPARISON
       The  following  table  compares  the POSIX pthreads and Solaris threads
       functions. When a comparable interface is not available either in POSIX
       pthreads or Solaris threads, a hyphen (-) appears in the column.

   Functions Related to Creation
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       pthread_create()thr_create()  pthread_attr_init()-  pthread_attr_setde‐
       tachstate()-    pthread_attr_getdetachstate()-   pthread_attr_setinher‐
       itsched()-    pthread_attr_getinheritsched()-    pthread_attr_setsched‐
       param()-  pthread_attr_getschedparam()-  pthread_attr_setschedpolicy()-
       pthread_attr_getschedpolicy()-                 pthread_attr_setscope()-
       pthread_attr_getscope()- pthread_attr_setstackaddr()- pthread_attr_get‐
       stackaddr()- pthread_attr_setstacksize()-  pthread_attr_getstacksize()-
       pthread_attr_getguardsize()-               pthread_attr_setguardsize()-
       pthread_attr_destroy()- -pthread_getattr_np() -thr_min_stack()


   Functions Related to Exit
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       pthread_exit()thr_exit() pthread_join()thr_join() pthread_detach()-


   Functions Related to Thread Specific Data
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       pthread_key_create()thr_keycreate()    pthread_setspecific()thr_setspe‐
       cific() pthread_getspecific()thr_getspecific() pthread_key_delete()-


   Functions Related to Signals
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       pthread_sigmask()thr_sigsetmask() pthread_kill()thr_kill()


   Functions Related to IDs
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       pthread_self()thr_self() pthread_equal()- -thr_main()


   Functions Related to Scheduling
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       -thr_yield()    -thr_suspend()    -thr_continue()    pthread_setconcur‐
       rency()thr_setconcurrency()      pthread_getconcurrency()thr_getconcur‐
       rency()     pthread_setschedparam()thr_setprio()      pthread_setsched‐
       prio()thr_setprio() pthread_getschedparam()thr_getprio()


   Functions Related to Cancellation
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       pthread_cancel()-  pthread_setcancelstate()-   pthread_setcanceltype()-
       pthread_testcancel()- pthread_cleanup_pop()- pthread_cleanup_push()-


   Functions Related to Mutexes
       tab();    cw(3.85i)    cw(1.65i)   lw(3.85i)   lw(1.65i)   POSIXSolaris
       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
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       pthread_cond_init()cond_init()   pthread_condattr_init()-  pthread_con‐
       dattr_setpshared()-     pthread_condattr_getpshared()-     pthread_con‐
       dattr_destroy()-   pthread_cond_wait()cond_wait()   pthread_cond_timed‐
       wait()cond_timedwait()               pthread_cond_signal()cond_signal()
       pthread_cond_broadcast()cond_broadcast()
       pthread_cond_destroy()cond_destroy()


   Functions Related to Reader/Writer Locking
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       pthread_rwlock_init()rwlock_init()   pthread_rwlock_rdlock()rw_rdlock()
       pthread_rwlock_tryrdlock()rw_tryrdlock()
       pthread_rwlock_wrlock()rw_wrlock()  pthread_rwlock_trywrlock()rw_trywr‐
       lock()                               pthread_rwlock_unlock()rw_unlock()
       pthread_rwlock_destroy()rwlock_destroy()     pthread_rwlockattr_init()-
       pthread_rwlockattr_destroy()-          pthread_rwlockattr_getpshared()-
       pthread_rwlockattr_gettype_np()-       pthread_rwlockattr_setpshared()-
       pthread_rwlockattr_settype_np()-


   Functions Related to Semaphores
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       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
       tab();    cw(2.75i)    cw(2.75i)   lw(2.75i)   lw(2.75i)   POSIXSolaris
       pthread_atfork()-


   Functions Related to Limits
       tab();   cw(2.75i)   cw(2.75i)   lw(2.75i)    lw(2.75i)    POSIXSolaris
       pthread_once()-


   Functions Related to Debugging
       tab();  cw(2.75i)  cw(2.75i) lw(2.75i) lw(2.75i) POSIXSolaris -thr_stk‐
       segment()


LOCKING
   Synchronization
       Multithreaded behavior is asynchronous, and  therefore,  optimized  for
       concurrent  and parallel processing. As threads, always from within the
       same process and sometimes from multiple processes, share  global  data
       with each other, they are not guaranteed exclusive access to the shared
       data at any point in time. Securing mutually exclusive access to shared
       data requires synchronization among the threads. Both POSIX and Solaris
       implement four synchronization  mechanisms:  mutexes,  condition  vari‐
       ables,  reader/writer locking (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, the lesser the concurrency.

   MT fork()
       If a threads program calls fork(2), it implicitly calls fork1(2), which
       replicates  only  the  calling  thread. Should there be any outstanding
       mutexes  throughout  the   process,   the   application   should   call
       pthread_atfork(3C) to wait for and acquire those mutexes prior to call‐
       ing fork().

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 exe‐
                      cute 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} priv‐
                      ilege asserted in its effective set.



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

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


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


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


   Solaris Threads
       Only  scheduling policy supported is SCHED_OTHER, which is timesharing,
       based on the TS scheduling class.

ERRORS
       In a multithreaded application, EINTR can  be  returned  from  blocking
       system calls when another thread calls forkall(2).

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:


       tab()  box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE TYPEAT‐
       TRIBUTE VALUE _ MT-LevelMT-Safe, Fork 1-Safe


SEE ALSO
       crle(1), fork(2), priocntl(2), pthread_atfork(3C),  pthread_create(3C),
       libpthread(3LIB),  librt(3LIB),  libthread(3LIB), attributes(7), privi‐
       leges(7), standards(7)


       Oracle Solaris 11.4 Linkers and Libraries Guide



Oracle Solaris 11.4               12 May 2017                       threads(7)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3