📄 posix.sgml
字号:
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate); int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr); int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr); int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize); int pthread_create( pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);pthread_t pthread_self( void ); int pthread_equal(pthread_t thread1, pthread_t thread2); void pthread_exit(void *retval); int pthread_join(pthread_t thread, void **thread_return); int pthread_detach(pthread_t thread); int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));</screen></sect2><!-- =================================================================== --><sect2><title>Functions Omitted</title> <para><none></para></sect2><!-- =================================================================== --><sect2><title>Notes</title><itemizedlist> <listitem> <para> The presence of thread support as a whole is controlled by the the CYGPKG_POSIX_PTHREAD configuration option. Note that disabling this will also disable many other features of the POSIX package, since these are intimately bound up with the thread mechanism. </para> </listitem> <listitem> <para> The default (non-scheduling) thread attributes are: </para> <screen> detachstate PTHREAD_CREATE_JOINABLE stackaddr unset stacksize unset </screen> </listitem> <listitem> <para> Dynamic thread stack allocation is only provided if there is an implementation of <emphasis>malloc()</emphasis> configured (i.e. a package implements the CYGINT_MEMALLOC_MALLOC_ALLOCATORS interface). If there is no malloc() available, then the thread creator must supply a stack. If only a stack address is supplied then the stack is assumed to be PTHREAD_STACK_MIN bytes long. This size is seldom useful for any but the most trivial of threads. If a different sized stack is used, both the stack address and stack size must be supplied. </para> </listitem> <listitem> <para> The value of PTHREAD_THREADS_MAX is supplied by the CYGNUM_POSIX_PTHREAD_THREADS_MAX option. This defines the maximum number of threads allowed. The POSIX standard requires this value to be at least 64, and this is the default value set. </para> </listitem> <listitem> <para> When the POSIX package is installed, the thread that calls <emphasis>main()</emphasis> is initialized as a POSIX thread. The priority of that thread is controlled by the CYGNUM_POSIX_MAIN_DEFAULT_PRIORITY option. </para> </listitem></itemizedlist></sect2></sect1><!-- }}} --><!-- {{{ Thread-Specific Data --><sect1 id="posix-thread-specific-data"><title>Thread-Specific Data [POSIX Section 17]</title><!-- =================================================================== --><sect2><title>Functions Implemented</title><screen>int pthread_key_create(pthread_key_t *key, void (*destructor)(void *)); int pthread_setspecific(pthread_key_t key, const void *pointer); void *pthread_getspecific(pthread_key_t key); int pthread_key_delete(pthread_key_t key);</screen></sect2><!-- =================================================================== --><sect2><title>Functions Omitted</title><para><none></para></sect2><!-- =================================================================== --><sect2><title>Notes</title><itemizedlist> <listitem> <para> The value of PTHREAD_DESTRUCTOR_ITERATIONS is provided by the CYGNUM_POSIX_PTHREAD_DESTRUCTOR_ITERATIONS option. This controls the number of times that a key destructor will be called while the data item remains non-NULL. </para> </listitem> <listitem> <para> The value of PTHREAD_KEYS_MAX is provided by the CYGNUM_POSIX_PTHREAD_KEYS_MAX option. This defines the maximum number of per-thread data items supported. The POSIX standard calls for this to be a minimum of 128, which is rather large for an embedded system. The default value for this option is set to 128 for compatibility but it should be reduced to a more usable value. </para> </listitem></itemizedlist></sect2></sect1><!-- }}} --><!-- {{{ Thread Cancellation --><sect1 id="posix-thread-cancellation"><title>Thread Cancellation [POSIX Section 18]</title><!-- =================================================================== --><sect2><title>Functions Implemented</title><screen>int pthread_cancel(pthread_t thread); int pthread_setcancelstate(int state, int *oldstate); int pthread_setcanceltype(int type, int *oldtype); void pthread_testcancel(void); void pthread_cleanup_push( void (*routine)(void *), void *arg); void pthread_cleanup_pop( int execute);</screen></sect2><!-- =================================================================== --><sect2><title>Functions Omitted</title><para><none></para></sect2><!-- =================================================================== --><sect2><title>Notes</title><para>Asynchronous cancellation is only partially implemented. Inparticular, cancellation may occur in unexpected places in somefunctions. It is strongly recommended that only synchronouscancellation be used. </para></sect2></sect1><!-- }}} --><!-- {{{ Non-POSIX Functions --><sect1 id="posix-non-posix-functions"><title>Non-POSIX Functions</title> <para>In addition to the standard POSIX functions defined above, thefollowing non-POSIX functions are defined in the FILEIO package.</para><!-- =================================================================== --><sect2><title>General I/O Functions</title><screen>int ioctl( int fd, CYG_ADDRWORD com, CYG_ADDRWORD data ); int select( int nfd, fd_set *in, fd_set *out, fd_set *ex, struct timeval *tv);</screen></sect2><!-- =================================================================== --><sect2><title>Socket Functions</title><screen>int socket( int domain, int type, int protocol); int bind( int s, const struct sockaddr *sa, unsigned int len); int listen( int s, int len); int accept( int s, struct sockaddr *sa, socklen_t *addrlen); int connect( int s, const struct sockaddr *sa, socklen_t len); int getpeername( int s, struct sockaddr *sa, socklen_t *len); int getsockname( int s, struct sockaddr *sa, socklen_t *len); int setsockopt( int s, int level, int optname, const void *optval, socklen_t optlen); int getsockopt( int s, int level, int optname, void *optval, socklen_t *optlen); ssize_t recvmsg( int s, struct msghdr *msg, int flags); ssize_t recvfrom( int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen); ssize_t recv( int s, void *buf, size_t len, int flags); ssize_t sendmsg( int s, const struct msghdr *msg, int flags); ssize_t sendto( int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); ssize_t send( int s, const void *buf, size_t len, int flags); int shutdown( int s, int how);</screen></sect2><!-- =================================================================== --><sect2><title>Notes</title><itemizedlist> <listitem> <para> The precise behaviour of these functions depends mainly on the functionality of the underlying filesystem or network stack to which they are applied. </para> </listitem></itemizedlist></sect2></sect1><!-- }}} --></chapter><!-- {{{ Bibliography --><bibliography id="posix-references-and-bibliography"><title>References and Bibliography</title> <bibliomixed> <bibliomisc>[Lewine]</bibliomisc> <author> <firstname>Donald</firstname> <othername>A.</othername> <surname>Lweine</surname> </author> <title>Posix Programmer’s Guide: Writing Portable Unix Programs With the POSIX.1 Standard O’Reilly & Associates; ISBN: 0937175730.</title></bibliomixed> <bibliomixed> <bibliomisc>[Lewis1]</bibliomisc> <author> <firstname>Bil</firstname> <surname>Lewis</surname> </author> <author> <firstname>Daniel</firstname> <othername>J.</othername> <surname>Berg</surname> </author> <title>Threads Primer: A Guide to Multithreaded Programming</title> <publishername>Prentice Hall</publishername> <isbn>ISBN: 013443698</isbn> </bibliomixed> <bibliomixed> <bibliomisc>[Lewis2]</bibliomisc> <author> <firstname>Bil</firstname> <surname>Lewis</surname> </author> <author> <firstname>Daniel</firstname> <othername>J.</othername> <surname>Berg</surname> </author> <title>Multithreaded Programming With Pthreads</title> <publisher> <publishername>Prentice Hall Computer Books</publishername> </publisher> <isbn>ISBN: 0136807291</isbn> </bibliomixed> <bibliomixed> <bibliomisc>[Nichols]</bibliomisc> <author> <firstname>Bradford</firstname> <surname>Nichols</surname> </author> <author> <firstname>Dick</firstname> <surname>Buttlar</surname> </author> <author> <firstname>Jacqueline</firstname> <othername>Proulx</othername> <surname>Farrell</surname> </author> <title>Pthreads Programming: A POSIX Standard for Better Multiprocessing (O’Reilly Nutshell)</title> <publisher><publishername>O’Reilly & Associates</publishername> </publisher> <isbn>ISBN: 1565921151</isbn> </bibliomixed> <bibliomixed> <bibliomisc>[Norton]</bibliomisc> <author> <firstname>Scott</firstname> <othername>J.</othername> <surname>Norton</surname> </author> <author> <firstname>Mark</firstname> <othername>D.</othername> <surname>Depasquale</surname> </author> <title>Thread Time: The MultiThreaded Programming Guide</title> <publisher><publishername>Prentice Hall</publishername> </publisher> <isbn>ISBN: 0131900676</isbn></bibliomixed> <bibliomixed> <bibliomisc>[POSIX]</bibliomisc> <title>Portable Operating System Interface(POSIX) -Part 1: System Application Programming Interface (API)[CLanguage]</title> <corpauthor>ISO/IEC 9945-1:1996, IEEE</corpauthor></bibliomixed> <bibliomixed> <bibliomisc>[SUS2]</bibliomisc> <title>Open Group; Single Unix Specification, Version 2</title> <bibliomisc><ulink url="http://www.opengroup.org/public/pubs/online/7908799/index.html">http://www.opengroup.org/public/pubs/online/7908799/index.html</ulink></bibliomisc> </bibliomixed> </bibliography><!-- }}} --></part>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -