pthread.3

来自「Linux下的中文输入法」· 3 代码 · 共 1,834 行 · 第 1/5 页

3
1,834
字号
The contents of the\&\fIparam\fRstructure are defined in\&\fI<sched.h\fR>.For the \s-1SCHED_FIFO\s0 and \s-1SCHED_RR\s0 policies,the only required member of\&\fIparam\fRis\&\fIsched_priority\fR..SH "RETURN VALUE".IX Header "RETURN VALUE"If successful, the\&\fI\fIpthread_attr_setschedparam()\fI\fRand\&\fI\fIpthread_attr_getschedparam()\fI\fRfunctions return zero.Otherwise, an error number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The\&\fI\fIpthread_attr_setschedparam()\fI\fRfunction 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..PPThe\&\fI\fIpthread_attr_setschedparam()\fI\fRand\&\fI\fIpthread_attr_getschedparam()\fI\fRfunctions will not return an error code of [\s-1EINTR\s0]..SH "EXAMPLES".IX Header "EXAMPLES"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"After these attributes have been set, a thread can be created withthe specified attributes using\&\fI\fIpthread_create()\fI\fR.Using these routines does not affect the current running thread..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_init()\fI\fR,\&\fI\fIpthread_attr_setscope()\fI\fR,\&\fI\fIpthread_attr_setinheritsched()\fI\fR,\&\fI\fIpthread_attr_setschedpolicy()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<pthread.h\fR>,\&\fI\fIpthread_setschedparam()\fI\fR,\&\fI<sched.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setschedpolicy,\fR \fBpthread_attr_getschedpolicy\fR\&\- set and get schedpolicy attribute(\fBREALTIME THREADS\fR).SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setschedpolicy(pthread_attr_t *\fIattr\fR, int \fIpolicy\fR);int pthread_attr_getschedpolicy(const pthread_attr_t *\fIattr\fR,int *\fIpolicy\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The functions\&\fI\fIpthread_attr_setschedpolicy()\fI\fRand\&\fI\fIpthread_attr_getschedpolicy()\fI\fR,respectively, set and get the\&\fIschedpolicy\fRattribute in the\&\fIattr\fRargument..PPThe supported values of\&\fIpolicy\fRinclude \s-1SCHED_FIFO\s0, \s-1SCHED_RR\s0 and \s-1SCHED_OTHER\s0,which are defined by the header\&\fI<sched.h\fR>.When threads executing with the scheduling policy\&\s-1SCHED_FIFO\s0 or \s-1SCHED_RR\s0 are waiting on a mutex,they acquire the mutex in priority order when the mutex is unlocked..SH "RETURN VALUE".IX Header "RETURN VALUE"If successful, the\&\fI\fIpthread_attr_setschedpolicy()\fI\fRand\&\fI\fIpthread_attr_getschedpolicy()\fI\fRfunctions return zero.Otherwise, an error number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The\&\fI\fIpthread_attr_setschedpolicy()\fI\fRand\&\fI\fIpthread_attr_getschedpolicy()\fI\fRfunctions 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_setschedpolicy()\fI\fRfunction 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"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"After these attributes have been set, a thread can be created withthe specified attributes using\&\fI\fIpthread_create()\fI\fR.Using these routines does not affect the current running thread..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_init()\fI\fR,\&\fI\fIpthread_attr_setscope()\fI\fR,\&\fI\fIpthread_attr_setinheritsched()\fI\fR,\&\fI\fIpthread_attr_setschedparam()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<pthread.h\fR>,\&\fI\fIpthread_setschedparam()\fI\fR,\&\fI<sched.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setscope,\fR \fBpthread_attr_getscope\fR\&\- set and get contentionscope attribute(\fBREALTIME THREADS\fR).SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setscope(pthread_attr_t *\fIattr\fR, int \fIcontentionscope\fR);int pthread_attr_getscope(const pthread_attr_t *\fIattr\fR,int *\fIcontentionscope\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The\&\fI\fIpthread_attr_setscope()\fI\fRand\&\fI\fIpthread_attr_getscope()\fI\fRfunctions are used to set and get the\&\fIcontentionscope\fRattribute in the\&\fIattr\fRobject..PPThe\&\fIcontentionscope\fRattribute may have the values\&\s-1PTHREAD_SCOPE_SYSTEM\s0,signifying system scheduling contention scope,or \s-1PTHREAD_SCOPE_PROCESS\s0,signifying process scheduling contention scope.The symbols \s-1PTHREAD_SCOPE_SYSTEM\s0 and \s-1PTHREAD_SCOPE_PROCESS\s0are defined by the header\&\fI<pthread.h\fR>..SH "RETURN VALUE".IX Header "RETURN VALUE"If successful, the\&\fI\fIpthread_attr_setscope()\fI\fRand\&\fI\fIpthread_attr_getscope()\fI\fRfunctions return zero.Otherwise, an error number is returned to indicate the error..SH "ERRORS".IX Header "ERRORS"The\&\fI\fIpthread_attr_setscope()\fI\fRand\&\fI\fIpthread_attr_getscope()\fI\fRfunctions 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_setscope()\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"None..SH "APPLICATION USAGE".IX Header "APPLICATION USAGE"After these attributes have been set, a thread can be created withthe specified attributes using\&\fI\fIpthread_create()\fI\fR.Using these routines does not affect the current running thread..SH "FUTURE DIRECTIONS".IX Header "FUTURE DIRECTIONS"None..SH "SEE ALSO".IX Header "SEE ALSO"\&\fI\fIpthread_attr_init()\fI\fR,\&\fI\fIpthread_attr_setinheritsched()\fI\fR,\&\fI\fIpthread_attr_setschedpolicy()\fI\fR,\&\fI\fIpthread_attr_setschedparam()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<pthread.h\fR>,\&\fI\fIpthread_setschedparam()\fI\fR,\&\fI<sched.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setstackaddr,\fR \fBpthread_attr_getstackaddr\fR\&\- set and get stackaddr attribute.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setstackaddr(pthread_attr_t *\fIattr\fR, void *\fIstackaddr\fR);int pthread_attr_getstackaddr(const pthread_attr_t *\fIattr\fR,void **\fIstackaddr\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The functions\&\fI\fIpthread_attr_setstackaddr()\fI\fRand\&\fI\fIpthread_attr_getstackaddr()\fI\fR,respectively, set and get the thread creation\&\fIstackaddr\fRattribute in the\&\fIattr\fRobject..PPThe\&\fIstackaddr\fRattribute specifies the location of storageto be used for the created thread's stack.The size of the storage is at least \s-1PTHREAD_STACK_MIN\s0..SH "RETURN VALUE".IX Header "RETURN VALUE"Upon successful completion,\&\fI\fIpthread_attr_setstackaddr()\fI\fRand\&\fI\fIpthread_attr_getstackaddr()\fI\fRreturn a value of 0.Otherwise, an error number is returned to indicate the error..PPThe\&\fI\fIpthread_attr_getstackaddr()\fI\fRfunction stores the\&\fIstackaddr\fRattribute value in\&\fIstackaddr\fRif successful..SH "ERRORS".IX Header "ERRORS"No errors are defined..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_setdetachstate()\fI\fR,\&\fI\fIpthread_attr_setstacksize()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<limits.h\fR>,\&\fI<pthread.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|_".IX Header "______________________________________________________________________".SH "NAME"\&\fBpthread_attr_setstacksize,\fR \fBpthread_attr_getstacksize\fR\&\- set and get stacksize attribute.SH "SYNOPSIS".IX Header "SYNOPSIS"#include <pthread.h>.PPint pthread_attr_setstacksize(pthread_attr_t *\fIattr\fR, size_t \fIstacksize\fR);int pthread_attr_getstacksize(const pthread_attr_t *\fIattr\fR,size_t *\fIstacksize\fR);.SH "DESCRIPTION".IX Header "DESCRIPTION"The functions\&\fI\fIpthread_attr_setstacksize()\fI\fRand\&\fI\fIpthread_attr_getstacksize()\fI\fR,respectively, set and get the thread creation\&\fIstacksize\fRattribute in the\&\fIattr\fRobject..PPThe\&\fIstacksize\fRattribute defines the minimum stack size (in bytes) allocated forthe created threads stack..SH "RETURN VALUE".IX Header "RETURN VALUE"Upon successful completion,\&\fI\fIpthread_attr_setstacksize()\fI\fRand\&\fI\fIpthread_attr_getstacksize()\fI\fRreturn a value of 0.Otherwise, an error number is returned to indicate the error.The\&\fI\fIpthread_attr_getstacksize()\fI\fRfunction stores the\&\fIstacksize\fRattribute value in\&\fIstacksize\fRif successful..SH "ERRORS".IX Header "ERRORS"The\&\fI\fIpthread_attr_setstacksize()\fI\fRfunction will fail if:.IP "[\s-1EINVAL\s0]" 4.IX Item "[EINVAL]"The value of\&\fIstacksize\fRis less than \s-1PTHREAD_STACK_MIN\s0 or exceeds a system-imposed limit..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_setdetachstate()\fI\fR,\&\fI\fIpthread_create()\fI\fR,\&\fI<limits.h\fR>,\&\fI<pthread.h\fR>..SH "_\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\|__\

⌨️ 快捷键说明

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