📄 pthread.pod
字号:
The I<guardsize> attribute is provided to the applicationfor two reasons:=over 4=item 1.Overflow 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.=item 2.When threads allocate large data structures on the stack,large guard areas may be needed to detect stack overflow.=backThe I<pthread_attr_getguardsize()> function gets the I<guardsize>attribute in the I<attr> object. This attribute is returned in theI<guardsize> parameter.The I<pthread_attr_setguardsize()> function sets the I<guardsize>attribute in the I<attr> object. The new value of this attribute isobtained from the I<guardsize> parameter. If I<guardsize> is zero,a guard area will not be provided for threads created with I<attr>.If I<guardsize> is greater than zero, a guard area of at least sizeI<guardsize> bytes is provided for each thread created with I<attr>.A conforming implementation is permitted to round up the valuecontained in I<guardsize> to a multiple of the configurable systemvariable PAGESIZE (see I<<sys/mman.h>>). If an implementation roundsup the value of I<guardsize> to a multiple of PAGESIZE, a call toI<pthread_attr_getguardsize()> specifying I<attr> will store in theI<guardsize> parameter the guard size specified by the previousI<pthread_attr_setguardsize()> function call.The default value of the I<guardsize> attribute is PAGESIZE bytes. Theactual value of PAGESIZE is implementation-dependent and may not be thesame on all implementations.If the I<stackaddr> attribute has been set (that is, the caller isallocating and managing its own thread stacks), the I<guardsize>attribute 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.=head1 RETURN VALUEIf successful, the I<pthread_attr_getguardsize()> andI<pthread_attr_setguardsize()> functions return zero. Otherwise, anerror number is returned to indicate the error.=head1 ERRORSThe I<pthread_attr_getguardsize()> and I<pthread_attr_setguardsize()>functions will fail if:=over 4=item [EINVAL]The attribute I<attr> is invalid.=item [EINVAL]The parameter I<guardsize> is invalid.=item [EINVAL]The parameter I<guardsize> contains an invalid value.=back=head1 EXAMPLESNone.=head1 APPLICATION USAGENone.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<<pthread.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setinheritsched,> B<pthread_attr_getinheritsched>- set and get inheritsched attribute(B<REALTIME THREADS>)=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setinheritsched(pthread_attr_t *I<attr>,int I<inheritsched>);int pthread_attr_getinheritsched(const pthread_attr_t *I<attr>,int *I<inheritsched>);=head1 DESCRIPTIONThe functions I<pthread_attr_setinheritsched()> andI<pthread_attr_getinheritsched()>, respectively, set and get theI<inheritsched> attribute in the I<attr> argument.When the attribute objects are used by I<pthread_create()>, theI<inheritsched> attribute determines how the other scheduling attributesof the created thread are to be set:=over 4=item PTHREAD_INHERIT_SCHEDSpecifies that the scheduling policy and associated attributes are tobe inherited from the creating thread, and the scheduling attributes inthis I<attr> argument are to be ignored.=item PTHREAD_EXPLICIT_SCHEDSpecifies that the scheduling policy and associated attributesare to be set to the corresponding values from this attribute object.=backThe symbols PTHREAD_INHERIT_SCHED and PTHREAD_EXPLICIT_SCHED are definedin the header I<<pthread.h>>.=head1 RETURN VALUEIf successful, the I<pthread_attr_setinheritsched()> andI<pthread_attr_getinheritsched()> functions return zero. Otherwise, anerror number is returned to indicate the error.=head1 ERRORSThe I<pthread_attr_setinheritsched()> andI<pthread_attr_getinheritsched()> functions will fail if:=over 4=item [ENOSYS]The option _POSIX_THREAD_PRIORITY_SCHEDULING is not defined and theimplementation does not support the function.=backThe I<pthread_attr_setinheritsched()> function may fail if:=over 4=item [EINVAL]The value of the attribute being set is not valid.=item [ENOTSUP]An attempt was made to set the attribute to an unsupported value.=back=head1 EXAMPLESNone.=head1 APPLICATION USAGEAfter these attributes have been set, a thread can be created with thespecified attributes using I<pthread_create()>. Using these routinesdoes not affect the current running thread.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_attr_init()>,I<pthread_attr_setscope()>,I<pthread_attr_setschedpolicy()>,I<pthread_attr_setschedparam()>,I<pthread_create()>,I<<pthread.h>>,I<pthread_setschedparam()>,I<<sched.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setschedparam,> B<pthread_attr_getschedparam>- set and get schedparam attribute=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setschedparam(pthread_attr_t *I<attr>, const struct sched_param *I<param>);int pthread_attr_getschedparam(const pthread_attr_t *I<attr>, struct sched_param *I<param>);=head1 DESCRIPTIONThe functions I<pthread_attr_setschedparam()> andI<pthread_attr_getschedparam()>, respectively, set and get thescheduling parameter attributes in the I<attr> argument. The contents ofthe I<param> structure are defined in I<<sched.h>>. For the SCHED_FIFOand SCHED_RR policies, the only required member of I<param> isI<sched_priority>.=head1 RETURN VALUEIf successful, the I<pthread_attr_setschedparam()> andI<pthread_attr_getschedparam()> functions return zero. Otherwise, anerror number is returned to indicate the error.=head1 ERRORSThe I<pthread_attr_setschedparam()> function may fail if:=over 4=item [EINVAL]The value of the attribute being set is not valid.=item [ENOTSUP]An attempt was made to set the attribute to an unsupported value.=backTheI<pthread_attr_setschedparam()>andI<pthread_attr_getschedparam()>functions will not return an error code of [EINTR].=head1 EXAMPLESNone.=head1 APPLICATION USAGEAfter these attributes have been set, a thread can be created with thespecified attributes using I<pthread_create()>. Using these routinesdoes not affect the current running thread.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_attr_init()>,I<pthread_attr_setscope()>,I<pthread_attr_setinheritsched()>,I<pthread_attr_setschedpolicy()>,I<pthread_create()>,I<<pthread.h>>,I<pthread_setschedparam()>,I<<sched.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setschedpolicy,> B<pthread_attr_getschedpolicy>- set and get schedpolicy attribute(B<REALTIME THREADS>)=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setschedpolicy(pthread_attr_t *I<attr>, int I<policy>);int pthread_attr_getschedpolicy(const pthread_attr_t *I<attr>,int *I<policy>);=head1 DESCRIPTIONThe functions I<pthread_attr_setschedpolicy()> andI<pthread_attr_getschedpolicy()>, respectively, set and get theI<schedpolicy> attribute in the I<attr> argument.The supported values of I<policy> include SCHED_FIFO, SCHED_RR andSCHED_OTHER, which are defined by the header I<<sched.h>>. When threadsexecuting with the scheduling policy SCHED_FIFO or SCHED_RR are waitingon a mutex, they acquire the mutex in priority order when the mutex isunlocked.=head1 RETURN VALUEIf successful, the I<pthread_attr_setschedpolicy()> andI<pthread_attr_getschedpolicy()> functions return zero. Otherwise, anerror number is returned to indicate the error.=head1 ERRORSThe I<pthread_attr_setschedpolicy()> andI<pthread_attr_getschedpolicy()> functions will fail if:=over 4=item [ENOSYS]The option _POSIX_THREAD_PRIORITY_SCHEDULING is not defined and theimplementation does not support the function.=backThe I<pthread_attr_setschedpolicy()> function may fail if:=over 4=item [EINVAL]The value of the attribute being set is not valid.=item [ENOTSUP]An attempt was made to set the attribute to an unsupported value.=back=head1 EXAMPLESNone.=head1 APPLICATION USAGEAfter these attributes have been set, a thread can be created with thespecified attributes using I<pthread_create()>. Using these routinesdoes not affect the current running thread.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_attr_init()>,I<pthread_attr_setscope()>,I<pthread_attr_setinheritsched()>,I<pthread_attr_setschedparam()>,I<pthread_create()>,I<<pthread.h>>,I<pthread_setschedparam()>,I<<sched.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setscope,> B<pthread_attr_getscope>- set and get contentionscope attribute(B<REALTIME THREADS>)=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setscope(pthread_attr_t *I<attr>, int I<contentionscope>);int pthread_attr_getscope(const pthread_attr_t *I<attr>,int *I<contentionscope>);=head1 DESCRIPTIONThe I<pthread_attr_setscope()> and I<pthread_attr_getscope()> functionsare used to set and get the I<contentionscope> attribute in the I<attr>object.The I<contentionscope> attribute may have the valuesPTHREAD_SCOPE_SYSTEM, signifying system scheduling contention scope, orPTHREAD_SCOPE_PROCESS, signifying process scheduling contention scope.The symbols PTHREAD_SCOPE_SYSTEM and PTHREAD_SCOPE_PROCESS are definedby the header I<<pthread.h>>.=head1 RETURN VALUEIf successful, the I<pthread_attr_setscope()> andI<pthread_attr_getscope()> functions return zero. Otherwise, an errornumber is returned to indicate the error.=head1 ERRORSThe I<pthread_attr_setscope()> and I<pthread_attr_getscope()> functionswill fail if:=over 4=item [ENOSYS]The option _POSIX_THREAD_PRIORITY_SCHEDULING is not defined and theimplementation does not support the function.=backTheI<pthread_attr_setscope()>,function may fail if:=over 4=item [EINVAL]The value of the attribute being set is not valid.=item [ENOTSUP]An attempt was made to set the attribute to an unsupported value.=back=head1 EXAMPLESNone.=head1 APPLICATION USAGEAfter these attributes have been set, a thread can be created with thespecified attributes using I<pthread_create()>. Using these routinesdoes not affect the current running thread.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_attr_init()>,I<pthread_attr_setinheritsched()>,I<pthread_attr_setschedpolicy()>,I<pthread_attr_setschedparam()>,I<pthread_create()>,I<<pthread.h>>,I<pthread_setschedparam()>,I<<sched.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setstackaddr,> B<pthread_attr_getstackaddr>- set and get stackaddr attribute=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setstackaddr(pthread_attr_t *I<attr>, void *I<stackaddr>);int pthread_attr_getstackaddr(const pthread_attr_t *I<attr>, void **I<stackaddr>);=head1 DESCRIPTIONThe functions I<pthread_attr_setstackaddr()> andI<pthread_attr_getstackaddr()>, respectively, set and get the threadcreation I<stackaddr> attribute in the I<attr> object.The I<stackaddr> attribute specifies the location of storage to be usedfor the created thread's stack. The size of the storage is at leastPTHREAD_STACK_MIN.=head1 RETURN VALUEUpon successful completion, I<pthread_attr_setstackaddr()> andI<pthread_attr_getstackaddr()> return a value of 0. Otherwise, an errornumber is returned to indicate the error.The I<pthread_attr_getstackaddr()> function stores the I<stackaddr>attribute value in I<stackaddr> if successful.=head1 ERRORSNo errors are defined.These functions will not return an error code of [EINTR].=head1 EXAMPLESNone.=head1 APPLICATION USAGENone.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_attr_init()>,I<pthread_attr_setdetachstate()>,I<pthread_attr_setstacksize()>,I<pthread_create()>,I<<limits.h>>,I<<pthread.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_attr_setstacksize,> B<pthread_attr_getstacksize>- set and get stacksize attribute=head1 SYNOPSIS#include <pthread.h>int pthread_attr_setstacksize(pthread_attr_t *I<attr>, size_t I<stacksize>);int pthread_attr_getstacksize(const pthread_attr_t *I<attr>,size_t *I<stacksize>);=head1 DESCRIPTIONThe functionsI<pthread_attr_setstacksize()>andI<pthread_attr_getstacksize()>,respectively, set and get the thread creationI<stacksize>attribute in theI<attr>object.TheI<stacksize>attribute defines the minimum stack size (in bytes) allocated forthe created threads stack.=head1 RETURN VALUEUpon successful completion,I<pthread_attr_setstacksize()>andI<pthread_attr_getstacksize()>return a value of 0.Otherwise, an error number is returned to indicate the error.TheI<pthread_attr_getstacksize()>function stores theI<stacksize>attribute value inI<stacksize>if successful.=head1 ERRORSTheI<pthread_attr_setstacksize()>function will fail if:=over 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -