⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pthread.3

📁 Linux下的中文输入法
💻 3
📖 第 1 页 / 共 5 页
字号:
Inclusion of the \fI<pthread.h\fR> header will make visible symbols definedin the headers \fI<sched.h\fR> and \fI<time.h\fR>..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"An interpretation request has been filed with \s-1IEEE\s0 \s-1PASC\s0 concerningrequirements for visibility of symbols in this header..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_init()\fI\fR,\&\fI\fIpthread_attr_getguardsize()\fI\fR,\&\fI\fIpthread_attr_setscope()\fI\fR,\&\fI\fIpthread_cancel()\fI\fR,\&\fI\fIpthread_cleanup_push()\fI\fR,\&\fI\fIpthread_cond_init()\fI\fR,\&\fI\fIpthread_cond_signal()\fI\fR,\&\fI\fIpthread_cond_wait()\fI\fR,\&\fI\fIpthread_condattr_init()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI\fIpthread_detach()\fI\fR,\&\fI\fIpthread_equal()\fI\fR,\&\fI\fIpthread_exit()\fI\fR,\&\fI\fIpthread_getconcurrency()\fI\fR,\&\fI\fIpthread_getschedparam()\fI\fR,\&\fI\fIpthread_join()\fI\fR,\&\fI\fIpthread_key_create()\fI\fR,\&\fI\fIpthread_key_delete()\fI\fR,\&\fI\fIpthread_mutex_init()\fI\fR,\&\fI\fIpthread_mutex_lock()\fI\fR,\&\fI\fIpthread_mutex_setprioceiling()\fI\fR,\&\fI\fIpthread_mutexattr_init()\fI\fR,\&\fI\fIpthread_mutexattr_gettype()\fI\fR,\&\fI\fIpthread_mutexattr_setprotocol()\fI\fR,\&\fI\fIpthread_once()\fI\fR,\&\fI\fIpthread_self()\fI\fR,\&\fI\fIpthread_setcancelstate()\fI\fR,\&\fI\fIpthread_setspecific()\fI\fR,\&\fI\fIpthread_rwlock_init()\fI\fR,\&\fI\fIpthread_rwlock_rdlock()\fI\fR,\&\fI\fIpthread_rwlock_unlock()\fI\fR,\&\fI\fIpthread_rwlock_wrlock()\fI\fR,\&\fI\fIpthread_rwlockattr_init()\fI\fR,\&\fI<sched.h\fR>,\&\fI<time.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_atfork\fR \- register fork handlers.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <sys/types.h>.PP#include <unistd.h>.PPint pthread_atfork(void (*\fIprepare\fR)(void), void (*\fIparent\fR)(void),void (*\fIchild\fR)(void));.SH "DESCRIPTION".IX Header "DESCRIPTION"The \fI\fIpthread_atfork()\fI\fR function declares fork handlers to be calledbefore and after \fI\fIfork()\fI\fR, in the context of the thread that called\&\fI\fIfork()\fI\fR. The \fIprepare\fR fork handler is called before \fI\fIfork()\fI\fRprocessing commences. The \fIparent\fR fork handle is called after\&\fI\fIfork()\fI\fR processing completes in the parent process. The \fIchild\fR forkhandler is called after \fI\fIfork()\fI\fR processing completes in the childprocess. If no handling is desired at one or more of these three points,the corresponding fork handler address(es) may be set to \s-1NULL\s0..PPThe order of calls to \fI\fIpthread_atfork()\fI\fR is significant. The \fIparent\fRand \fIchild\fR fork handlers are called in the order in which they wereestablished by calls to \fI\fIpthread_atfork()\fI\fR. The \fIprepare\fR forkhandlers are called in the opposite order..SH "RETURN VALUE".IX Header "RETURN VALUE"Upon successful completion, \fI\fIpthread_atfork()\fI\fR returns a value of zero.Otherwise, an error number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The \fI\fIpthread_atfork()\fI\fR function will fail if:.IP "[\s-1ENOMEM\s0]" 4.IX Item "[ENOMEM]"Insufficient table space exists to record the fork handler addresses..PPThe \fI\fIpthread_atfork()\fI\fR function will not return an error code of[\s-1EINTR\s0]..SH "EXAMPLES".IX Header "EXAMPLES"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"None..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIatexit()\fI\fR,\&\fI\fIfork()\fI\fR,\&\fI<sys/types.h\fR>.SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_init,\fR \fBpthread_attr_destroy\fR\&\- initialise and destroy threads attribute object.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_init(pthread_attr_t *\fIattr\fR);.PPint pthread_attr_destroy(pthread_attr_t *\fIattr\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The function \fI\fIpthread_attr_init()\fI\fR initialises a thread attributesobject \fIattr\fR with the default value for all of the individualattributes used by a given implementation..PPThe resulting attribute object (possibly modified by setting individualattribute values), when used by \fI\fIpthread_create()\fI\fR, defines theattributes of the thread created. A single attributes object can be usedin multiple simultaneous calls to \fI\fIpthread_create()\fI\fR..PPThe \fI\fIpthread_attr_destroy()\fI\fR function is used to destroy a threadattributes object. An implementation may cause \fI\fIpthread_attr_destroy()\fI\fRto set \fIattr\fR to an implementation-dependent invalid value. Thebehaviour of using the attribute after it has been destroyed isundefined..SH "RETURN VALUE".IX Header "RETURN VALUE"Upon successful completion, \fI\fIpthread_attr_init()\fI\fR and\&\fI\fIpthread_attr_destroy()\fI\fR return a value of 0. Otherwise, an errornumber is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The \fI\fIpthread_attr_init()\fI\fR function will fail if:.IP "[\s-1ENOMEM\s0]" 4.IX Item "[ENOMEM]"Insufficient memory exists to initialise the thread attributes object..PPThese functions will not return an error code of [\s-1EINTR\s0]..SH "EXAMPLES".IX Header "EXAMPLES"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"None..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_setstackaddr()\fI\fR,\&\fI\fIpthread_attr_setstacksize()\fI\fR,\&\fI\fIpthread_attr_setdetachstate()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<pthread.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setdetachstate,\fR \fBpthread_attr_getdetachstate\fR\&\- set and get detachstate attribute.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setdetachstate(pthread_attr_t *\fIattr\fR, int \fIdetachstate\fR);.PPint pthread_attr_getdetachstate(const pthread_attr_t *\fIattr\fR, int *\fIdetachstate\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The \fIdetachstate\fR attribute controls whether the thread is created in adetached state. If the thread is created detached, then use of the \s-1ID\s0 ofthe newly created thread by the \fI\fIpthread_detach()\fI\fR or \fI\fIpthread_join()\fI\fRfunction is an error..PPThe \fI\fIpthread_attr_setdetachstate()\fI\fR and\&\fI\fIpthread_attr_getdetachstate()\fI\fR, respectively, set and get the\&\fIdetachstate\fR attribute in the \fIattr\fR object..PPThe \fIdetachstate\fR can be set to either \s-1PTHREAD_CREATE_DETACHED\s0 or\&\s-1PTHREAD_CREATE_JOINABLE\s0. A value of \s-1PTHREAD_CREATE_DETACHED\s0 causesall threads created with \fIattr\fR to be in the detached state, whereasusing a value of \s-1PTHREAD_CREATE_JOINABLE\s0 causes all threads createdwith \fIattr\fR to be in the joinable state. The default value of the\&\fIdetachstate\fR attribute is \s-1PTHREAD_CREATE_JOINABLE\s0 ..SH "RETURN VALUE".IX Header "RETURN VALUE"Upon successful completion, \fI\fIpthread_attr_setdetachstate()\fI\fR and\&\fI\fIpthread_attr_getdetachstate()\fI\fR return a value of 0. Otherwise, anerror number is returned to indicate the error..PPThe \fI\fIpthread_attr_getdetachstate()\fI\fR function stores the value of the\&\fIdetachstate\fR attribute in \fIdetachstate\fR if successful..SH "ERRORS".IX Header "ERRORS"The \fI\fIpthread_attr_setdetachstate()\fI\fR function will fail if:.IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The value of \fIdetachstate\fR was not valid.PPThese functions will not return an error code of [\s-1EINTR\s0]..SH "EXAMPLES".IX Header "EXAMPLES"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"None..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_init()\fI\fR,\&\fI\fIpthread_attr_setstackaddr()\fI\fR,\&\fI\fIpthread_attr_setstacksize()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<pthread.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_getguardsize,\fR \fBpthread_attr_setguardsize\fR \-get or set the thread guardsize attribute.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_getguardsize(const pthread_attr_t \fI*attr\fR, size_t\&\fI*guardsize\fR); int pthread_attr_setguardsize(pthread_attr_t \fI*attr\fR,size_t \fIguardsize\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The \fIguardsize\fR attribute controls the size of the guard area for thecreated thread's stack. The \fIguardsize\fR attribute provides protectionagainst overflow of the stack pointer. If a thread's stack is createdwith guard protection, the implementation allocates extra memory at theoverflow end of the stack as a buffer against stack overflow of thestack pointer. If an application overflows into this buffer an errorresults (possibly in a \s-1SIGSEGV\s0 signal being delivered to the thread)..PPThe \fIguardsize\fR attribute is provided to the applicationfor two reasons:.IP "1." 4Overflow protection can potentially result in wasted system resources.An application that creates a large number of threads, and which knowsits threads will never overflow their stack, can save system resourcesby turning off guard areas..IP "2." 4When threads allocate large data structures on the stack,large guard areas may be needed to detect stack overflow..PPThe \fI\fIpthread_attr_getguardsize()\fI\fR function gets the \fIguardsize\fRattribute in the \fIattr\fR object. This attribute is returned in the\&\fIguardsize\fR parameter..PPThe \fI\fIpthread_attr_setguardsize()\fI\fR function sets the \fIguardsize\fRattribute in the \fIattr\fR object. The new value of this attribute isobtained from the \fIguardsize\fR parameter. If \fIguardsize\fR is zero,a guard area will not be provided for threads created with \fIattr\fR.If \fIguardsize\fR is greater than zero, a guard area of at least size\&\fIguardsize\fR bytes is provided for each thread created with \fIattr\fR..PPA conforming implementation is permitted to round up the valuecontained in \fIguardsize\fR to a multiple of the configurable systemvariable \s-1PAGESIZE\s0 (see \fI<sys/mman.h\fR>). If an implementation roundsup the value of \fIguardsize\fR to a multiple of \s-1PAGESIZE\s0, a call to\&\fI\fIpthread_attr_getguardsize()\fI\fR specifying \fIattr\fR will store in the\&\fIguardsize\fR parameter the guard size specified by the previous\&\fI\fIpthread_attr_setguardsize()\fI\fR function call..PPThe default value of the \fIguardsize\fR attribute is \s-1PAGESIZE\s0 bytes. Theactual value of \s-1PAGESIZE\s0 is implementation-dependent and may not be thesame on all implementations..PPIf the \fIstackaddr\fR attribute has been set (that is, the caller isallocating and managing its own thread stacks), the \fIguardsize\fRattribute is ignored and no protection will be provided by theimplementation. It is the responsibility of the application to managestack overflow along with stack allocation and management in this case..SH "RETURN VALUE".IX Header "RETURN VALUE"If successful, the \fI\fIpthread_attr_getguardsize()\fI\fR and\&\fI\fIpthread_attr_setguardsize()\fI\fR functions return zero. Otherwise, anerror number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The \fI\fIpthread_attr_getguardsize()\fI\fR and \fI\fIpthread_attr_setguardsize()\fI\fRfunctions will fail if:.IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The attribute \fIattr\fR is invalid..IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The parameter \fIguardsize\fR is invalid..IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The parameter \fIguardsize\fR contains an invalid value..SH "EXAMPLES".IX Header "EXAMPLES"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"None..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI<pthread.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setinheritsched,\fR \fBpthread_attr_getinheritsched\fR\&\- set and get inheritsched attribute(\fBREALTIME THREADS\fR).SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setinheritsched(pthread_attr_t *\fIattr\fR,int \fIinheritsched\fR);int pthread_attr_getinheritsched(const pthread_attr_t *\fIattr\fR,int *\fIinheritsched\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The functions \fI\fIpthread_attr_setinheritsched()\fI\fR and\&\fI\fIpthread_attr_getinheritsched()\fI\fR, respectively, set and get the\&\fIinheritsched\fR attribute in the \fIattr\fR argument..PPWhen the attribute objects are used by \fI\fIpthread_create()\fI\fR, the\&\fIinheritsched\fR attribute determines how the other scheduling attributesof the created thread are to be set:.IP "\s-1PTHREAD_INHERIT_SCHED\s0" 4.IX Item "PTHREAD_INHERIT_SCHED"Specifies that the scheduling policy and associated attributes are tobe inherited from the creating thread, and the scheduling attributes inthis \fIattr\fR argument are to be ignored..IP "\s-1PTHREAD_EXPLICIT_SCHED\s0" 4.IX Item "PTHREAD_EXPLICIT_SCHED"Specifies that the scheduling policy and associated attributesare to be set to the corresponding values from this attribute object..PPThe symbols \s-1PTHREAD_INHERIT_SCHED\s0 and \s-1PTHREAD_EXPLICIT_SCHED\s0 are definedin the header \fI<pthread.h\fR>..SH "RETURN VALUE".IX Header "RETURN VALUE"If successful, the \fI\fIpthread_attr_setinheritsched()\fI\fR and\&\fI\fIpthread_attr_getinheritsched()\fI\fR functions return zero. Otherwise, anerror number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The \fI\fIpthread_attr_setinheritsched()\fI\fR and\&\fI\fIpthread_attr_getinheritsched()\fI\fR functions will fail if:.IP "[\s-1ENOSYS\s0]" 4.IX Item "[ENOSYS]"The option _POSIX_THREAD_PRIORITY_SCHEDULING is not defined and theimplementation does not support the function..PPThe \fI\fIpthread_attr_setinheritsched()\fI\fR function may fail if:.IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The value of the attribute being set is not valid..IP "[\s-1ENOTSUP\s0]" 4.IX Item "[ENOTSUP]"An attempt was made to set the attribute to an unsupported value..SH "EXAMPLES".IX Header "EXAMPLES"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -