📄 pthread.pod
字号:
I<pthread_create()>.Using these routines does 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 functionsI<pthread_attr_setschedpolicy()>andI<pthread_attr_getschedpolicy()>,respectively, set and get theI<schedpolicy>attribute in theI<attr>argument.The supported values ofI<policy>include SCHED_FIFO, SCHED_RR and SCHED_OTHER,which are defined by the headerI<<sched.h>>.When threads executing with the scheduling policySCHED_FIFO or SCHED_RR are waiting on a mutex,they acquire the mutex in priority order when the mutex is unlocked.=head1 RETURN VALUEIf successful, theI<pthread_attr_setschedpolicy()>andI<pthread_attr_getschedpolicy()>functions return zero.Otherwise, an error number is returned to indicate the error.=head1 ERRORSTheI<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.=backTheI<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 withthe specified attributes usingI<pthread_create()>.Using these routines does 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 DESCRIPTIONTheI<pthread_attr_setscope()>andI<pthread_attr_getscope()>functions are used to set and get theI<contentionscope>attribute in theI<attr>object.TheI<contentionscope>attribute may have the valuesPTHREAD_SCOPE_SYSTEM,signifying system scheduling contention scope,or PTHREAD_SCOPE_PROCESS,signifying process scheduling contention scope.The symbols PTHREAD_SCOPE_SYSTEM and PTHREAD_SCOPE_PROCESSare defined by the headerI<<pthread.h>>.=head1 RETURN VALUEIf successful, theI<pthread_attr_setscope()>andI<pthread_attr_getscope()>functions return zero.Otherwise, an error number is returned to indicate the error.=head1 ERRORSTheI<pthread_attr_setscope()>andI<pthread_attr_getscope()>functions will 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 withthe specified attributes usingI<pthread_create()>.Using these routines does 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 functionsI<pthread_attr_setstackaddr()>andI<pthread_attr_getstackaddr()>,respectively, set and get the thread creationI<stackaddr>attribute in theI<attr>object.TheI<stackaddr>attribute specifies the location of storageto be used for the created thread's stack.The size of the storage is at least PTHREAD_STACK_MIN.=head1 RETURN VALUEUpon successful completion,I<pthread_attr_setstackaddr()>andI<pthread_attr_getstackaddr()>return a value of 0.Otherwise, an error number is returned to indicate the error.TheI<pthread_attr_getstackaddr()>function stores theI<stackaddr>attribute value inI<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=item [EINVAL]The value ofI<stacksize>is less than PTHREAD_STACK_MIN or exceeds a system-imposed limit.=backThese 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_setstackaddr()>,I<pthread_attr_setdetachstate()>,I<pthread_create()>,I<<limits.h>>,I<<pthread.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_cancel> - cancel execution of a thread=head1 SYNOPSIS#include <pthread.h>int pthread_cancel(pthread_t I<thread>);=head1 DESCRIPTIONTheI<pthread_cancel()>function requests thatI<thread>be canceled.The target threads cancelability state and typedetermines when the cancellation takes effect.When the cancellation is acted on, thecancellation cleanup handlers forI<thread>are called.When the last cancellation cleanup handler returns,the thread-specific data destructor functions are called forI<thread>.When the last destructor function returns,I<thread>is terminated.The cancellation processing in the target thread runs asynchronouslywith respect to the calling thread returning fromI<pthread_cancel()>.=head1 RETURN VALUEIf successful, theI<pthread_cancel()>function returns zero.Otherwise, an error number is returned to indicate the error.=head1 ERRORSTheI<pthread_cancel()>function may fail if:=over 4=item [ESRCH]No thread could be found corresponding to that specifiedby the given thread ID.=backTheI<pthread_cancel()>function will not return an error code of [EINTR].=head1 EXAMPLESNone.=head1 APPLICATION USAGENone.=head1 FUTURE DIRECTIONSNone.=head1 SEE ALSOI<pthread_exit()>,I<pthread_join()>,I<pthread_setcancelstate()>,I<pthread_cond_wait()>,I<pthread_cond_timedwait()>,I<<pthread.h>>.=head1 ______________________________________________________________________=head1 NAMEB<pthread_cleanup_push,> B<pthread_cleanup_pop> - establish cancellation handlers=head1 SYNOPSIS#include <pthread.h>void pthread_cleanup_push(void (*I<routine>)(void*), void *I<arg>);void pthread_cleanup_pop(int I<execute>);=head1 DESCRIPTIONTheI<pthread_cleanup_push()>function pushes the specified cancellation cleanup handlerI<routine>onto the calling thread's cancellation cleanup stack.The cancellation cleanup handler is popped from thecancellation cleanup stack and invoked with the argumentI<arg>when: (a) the thread exits (that is, callsI<pthread_exit()>),(b) the thread acts upon a cancellation request, or(c) the thread callsI<pthread_cleanup_pop()>with a non-zeroI<execute>argument.TheI<pthread_cleanup_pop()>function removes the routine at the top of the calling thread'scancellation cleanup stack and optionally invokes it (ifI<execute>is non-zero).These functions may be implemented as macros and willappear as statements and in pairs within the same lexical scope (that is, theI<pthread_cleanup_push()>macro may be thought to expand to a token list whose firsttoken isB<`{'>withI<pthread_cleanup_pop()>expanding to a token list whose last token is the correspondingB<`}'>.The effect of callingI<longjmp()>orI<siglongjmp()>is undefined if there have been any calls toI<pthread_cleanup_push()>orI<pthread_cleanup_pop()>made without the matching callsince the jump buffer was filled.The effect of callingI<longjmp()>orI<siglongjmp()>from inside a cancellation cleanup handler is alsoundefined unless the jump buffer was also filled in thecancellation cleanup handler.=head1 RETURN VALUETheI<pthread_cleanup_push()>andI<pthread_cleanup_pop()>functions return no value.=head1 ERRORSNo errors are defined.These functions will not return an error code of [EINTR].=head1 EXAMPLESNone.=head1 APPLICATION USAGE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -