📄 pthread.3
字号:
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14.\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. | will give a.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'.\" expand to `' in nroff, nothing in troff, for use with C<>..tr \(*W-|\(bv\*(Tr.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..if \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.\".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..hy 0.if n .na.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "pthread 3".TH pthread 3 "GNU Pth 2.0.3" "03-Dec-2004" "POSIX Threading API of GNU Pth".SH "NAME"\&\fBpthread\fR \- POSIX.1c Threading API of GNU Pth.SH "VERSION".IX Header "VERSION"\&\s-1GNU\s0 Pth \s-12.0.3 (03-Dec-2004)\s0.SH "SYNOPSIS".IX Header "SYNOPSIS"\&\fBApplication Makefiles:\fR.PP.Vb 4\& # manually\& CFLAGS=-I/path/to/pth/include\& LDFLAGS=-L/path/to/pth/lib\& LIBS=-lpthread.Ve.PP.Vb 4\& # automatically\& CFLAGS=`pthread-config --cflags`\& LDFLAGS=`pthread-config --ldflags`\& LIBS=`pthread-config --libs`.Ve.PP\&\fBApplication source files:\fR.PP.Vb 1\& #include <pthread.h>.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION".Sh "Overview".IX Subsection "Overview"This is the \s-1IEEE\s0 Std. 1003.1c (\*(L"\s-1POSIX\s0.1c\*(R") conforming threading \s-1API\s0 of\&\s-1GNU\s0 Portable Threads (\fBPth\fR). This \s-1API\s0 is commonly known as ``\fI\s-1POSIX\s0threads\fR'' or in short ``\fIPthreads\fR''. It is provided by \fBPth\fR withthe intention of backward compatibility to existing multithreadedapplications. It is implemented by mapping the various Pthread \s-1API\s0functions to the corresponding native \fBPth\fR \s-1API\s0 functions..Sh "Supported Features".IX Subsection "Supported Features"The following defined feature macros in \f(CW\*(C`pthread.h\*(C'\fR indicate supportedfeatures:.PP.Vb 3\& #define _POSIX_THREADS\& #define _POSIX_THREAD_ATTR_STACKADDR\& #define _POSIX_THREAD_ATTR_STACKSIZE.Ve.PPThe following undefined feature macros in \f(CW\*(C`pthread.h\*(C'\fR indicate (still)unsupported features:.PP.Vb 5\& #undef _POSIX_THREAD_PRIORITY_SCHEDULING\& #undef _POSIX_THREAD_PRIO_INHERIT\& #undef _POSIX_THREAD_PRIO_PROTECT\& #undef _POSIX_THREAD_PROCESS_SHARED\& #undef _POSIX_THREAD_SAFE_FUNCTIONS.Ve.Sh "Notes".IX Subsection "Notes"A few notes which you should keep in mind when working with the \fBPth\fR Pthread\&\s-1API\s0..IP "\fBNon-Preemptive Scheduling\fR" 4.IX Item "Non-Preemptive Scheduling"First you have to always remember when working with this Pthread library thatit uses non-preemptive scheduling, because it is directly based on \fBPth\fR(\fBPth\fR for portability reasons is a pure non-preemptive thread schedulingsystem). So there is no implicit yielding of execution control unless you can\&\f(CW\*(C`pthread_*\*(C'\fR functions which could block and you cannot expect granularconcurrency in your application, of course. Nevertheless the responsivenessand concurrency of an event driven application is increased greatly because ofoverlapping I/O..IP "\fBConflicts with Vendor Implementation\fR" 4.IX Item "Conflicts with Vendor Implementation"There can be a conflict between the \fBPth\fR \f(CW\*(C`pthread.h\*(C'\fR header and a possiblyexisting vendor \f(CW\*(C`/usr/include/pthread.h\*(C'\fR header which was implicitly includedby some standard vendor headers (like \f(CW\*(C`/usr/include/unistd.h\*(C'\fR). When thisoccurs try to ``\f(CW\*(C`#define\*(C'\fR'' header-dependent values which prevent theinclusion of the vendor header..Sh "Further Reading".IX Subsection "Further Reading"There is ``\fIThe Single \s-1UNIX\s0 Specification, Version2 \- Threads\fR'', from \fIThe Open Group\fR of 1997 underhttp://www.opengroup.org/onlinepubs/007908799/xsh/threads.html. This isa very complete publically available description of the Pthread \s-1API\s0. Forconvinience reasons, a translated copy of these freely available \s-1HTML\s0pages are appended to this manpage below. These are \fICopyright (C) 1997The Open Group\fR..PPSecond, you can also buy the official standard from \s-1IEEE\s0. It is the \s-1IEEE\s0\&\s-1POSIX\s0 1003.1c\-1995 standard (also known as \s-1ISO/IEC\s0 9945\-1:1996), whichis available as part of the \s-1ANSI/IEEE\s0 1003.1, 1996 edition, standard..PPFinally you can look at the files \f(CW\*(C`pthread.c\*(C'\fR and \f(CW\*(C`pthread.h\*(C'\fR in the \fBPth\fRsource tree for details of the implementation, of course..SH "SEE ALSO".IX Header "SEE ALSO"\&\fIpthread\-config\fR\|(1), \fIpth\fR\|(3)..SH "AUTHOR".IX Header "AUTHOR".Vb 3\& Ralf S. Engelschall\& rse@engelschall.com\& www.engelschall.com.Ve.SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread.h\fR \- threads.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.SH "DESCRIPTION".IX Header "DESCRIPTION"The\&\fI<pthread.h\fR>header defines the following symbols:.PP.Vb 24\& PTHREAD_CANCEL_ASYNCHRONOUS\& PTHREAD_CANCEL_ENABLE\& PTHREAD_CANCEL_DEFERRED\& PTHREAD_CANCEL_DISABLE\& PTHREAD_CANCELED\& PTHREAD_COND_INITIALIZER\& PTHREAD_CREATE_DETACHED\& PTHREAD_CREATE_JOINABLE\& PTHREAD_EXPLICIT_SCHED\& PTHREAD_INHERIT_SCHED\& PTHREAD_MUTEX_DEFAULT\& PTHREAD_MUTEX_ERRORCHECK\& PTHREAD_MUTEX_NORMAL\& PTHREAD_MUTEX_INITIALIZER\& PTHREAD_MUTEX_RECURSIVE\& PTHREAD_ONCE_INIT\& PTHREAD_PRIO_INHERIT\& PTHREAD_PRIO_NONE\& PTHREAD_PRIO_PROTECT\& PTHREAD_PROCESS_SHARED\& PTHREAD_PROCESS_PRIVATE\& PTHREAD_RWLOCK_INITIALIZER\& PTHREAD_SCOPE_PROCESS\& PTHREAD_SCOPE_SYSTEM.Ve.PPThe \fBpthread_attr_t\fR, \fBpthread_cond_t\fR, \fBpthread_condattr_t\fR,\&\fBpthread_key_t\fR, \fBpthread_mutex_t\fR, \fBpthread_mutexattr_t\fR,\&\fBpthread_once_t\fR, \fBpthread_rwlock_t\fR, \fBpthread_rwlockattr_t\fR and\&\fBpthread_t\fR types are defined as described in \fI<sys/types.h\fR>..PPThe following are declared as functions and may also be declared asmacros. Function prototypes must be provided for use with an \s-1ISO\s0 Ccompiler..PP.Vb 77\& int pthread_attr_destroy(pthread_attr_t *);\& int pthread_attr_getdetachstate(const pthread_attr_t *, int *);\& int pthread_attr_getguardsize(const pthread_attr_t *, size_t *);\& int pthread_attr_getinheritsched(const pthread_attr_t *, int *);\& int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *);\& int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);\& int pthread_attr_getscope(const pthread_attr_t *, int *);\& int pthread_attr_getstackaddr(const pthread_attr_t *, void **);\& int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);\& int pthread_attr_init(pthread_attr_t *);\& int pthread_attr_setdetachstate(pthread_attr_t *, int);\& int pthread_attr_setguardsize(pthread_attr_t *, size_t);\& int pthread_attr_setinheritsched(pthread_attr_t *, int);\& int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *);\& int pthread_attr_setschedpolicy(pthread_attr_t *, int);\& int pthread_attr_setscope(pthread_attr_t *, int);\& int pthread_attr_setstackaddr(pthread_attr_t *, void *);\& int pthread_attr_setstacksize(pthread_attr_t *, size_t);\& int pthread_cancel(pthread_t);\& void pthread_cleanup_push(void*), void *);\& void pthread_cleanup_pop(int);\& int pthread_cond_broadcast(pthread_cond_t *);\& int pthread_cond_destroy(pthread_cond_t *);\& int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *);\& int pthread_cond_signal(pthread_cond_t *);\& int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *);\& int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);\& int pthread_condattr_destroy(pthread_condattr_t *);\& int pthread_condattr_getpshared(const pthread_condattr_t *, int *);\& int pthread_condattr_init(pthread_condattr_t *);\& int pthread_condattr_setpshared(pthread_condattr_t *, int);\& int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);\& int pthread_detach(pthread_t);\& int pthread_equal(pthread_t, pthread_t);\& void pthread_exit(void *);\& int pthread_getconcurrency(void);\& int pthread_getschedparam(pthread_t, int *, struct sched_param *);\& void *pthread_getspecific(pthread_key_t);\& int pthread_join(pthread_t, void **);\& int pthread_key_create(pthread_key_t *, void (*)(void *));\& int pthread_key_delete(pthread_key_t);\& int pthread_mutex_destroy(pthread_mutex_t *);\& int pthread_mutex_getprioceiling(const pthread_mutex_t *, int *);\& int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);\& int pthread_mutex_lock(pthread_mutex_t *);\& int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);\& int pthread_mutex_trylock(pthread_mutex_t *);\& int pthread_mutex_unlock(pthread_mutex_t *);\& int pthread_mutexattr_destroy(pthread_mutexattr_t *);\& int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);\& int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);\& int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);\& int pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *);\& int pthread_mutexattr_init(pthread_mutexattr_t *);\& int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);\& int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);\& int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);\& int pthread_mutexattr_settype(pthread_mutexattr_t *, int);\& int pthread_once(pthread_once_t *, void (*)(void));\& int pthread_rwlock_destroy(pthread_rwlock_t *);\& int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);\& int pthread_rwlock_rdlock(pthread_rwlock_t *);\& int pthread_rwlock_tryrdlock(pthread_rwlock_t *);\& int pthread_rwlock_trywrlock(pthread_rwlock_t *);\& int pthread_rwlock_unlock(pthread_rwlock_t *);\& int pthread_rwlock_wrlock(pthread_rwlock_t *);\& int pthread_rwlockattr_destroy(pthread_rwlockattr_t *);\& int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, int *);\& int pthread_rwlockattr_init(pthread_rwlockattr_t *);\& int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int);\& pthread_t pthread_self(void);\& int pthread_setcancelstate(int, int *);\& int pthread_setcanceltype(int, int *);\& int pthread_setconcurrency(int);\& int pthread_setschedparam(pthread_t, int, const struct sched_param *);\& int pthread_setspecific(pthread_key_t, const void *);\& void pthread_testcancel(void);.Ve.PP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -