📄 pthread_create.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>pthread_create</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_007_1315"> </a>NAME</h4><blockquote>pthread_create - thread creation</blockquote><h4><a name = "tag_000_007_1316"> </a>SYNOPSIS</h4><blockquote><pre><code>#include <<a href="pthread.h.html">pthread.h</a>>int pthread_create(pthread_t *<i>thread</i>, const pthread_attr_t *<i>attr</i>, void *(*<i>start_routine</i>)(void*), void *<i>arg</i>);</code></pre></blockquote><h4><a name = "tag_000_007_1317"> </a>DESCRIPTION</h4><blockquote>The<i>pthread_create()</i>function is used to create a new thread, with attributes specified by<i>attr</i>,within a process.If<i>attr</i>is NULL,the default attributes are used.If the attributes specified by<i>attr</i>are modified later, the thread's attributes are not affected.Upon successful completion,<i>pthread_create()</i>stores the ID of the created thread in the location referenced by<i>thread</i>.<p>The thread is created executing<i>start_routine</i>with<i>arg</i>as its sole argument.If the<i>start_routine</i>returns, the effect is as if there was an implicit call to<i><a href="pthread_exit.html">pthread_exit()</a></i>using the return value of<i>start_routine</i>as the exit status.Note that the thread in which<i>main()</i>was originally invoked differs from this.When it returns from<i>main()</i>,the effect is as if there was an implicit call to<i><a href="exit.html">exit()</a></i>using the return value of<i>main()</i>as the exit status.<p>The signal state of the new thread is initialised as follows:<ul><p><li>The signal mask is inherited from the creating thread.<p><li>The set of signals pending for the new thread is empty.<p></ul><p>If<i>pthread_create()</i>fails, no new thread is createdand the contents of the location referenced by<i>thread</i>are undefined.</blockquote><h4><a name = "tag_000_007_1318"> </a>RETURN VALUE</h4><blockquote>If successful, the<i>pthread_create()</i>function returns zero.Otherwise, an error number is returned to indicate the error.</blockquote><h4><a name = "tag_000_007_1319"> </a>ERRORS</h4><blockquote>The <i>pthread_create()</i>function will fail if:<dl compact><dt>[EAGAIN]<dd>The system lacked the necessary resources to create another thread,or the system-imposed limit on the total number of threadsin a process PTHREAD_THREADS_MAX would be exceeded.<dt>[EINVAL]<dd>The value specified by<i>attr</i>is invalid.<dt>[EPERM]<dd>The caller does not have appropriate permission to set the requiredscheduling parameters or scheduling policy.</dl><p>The<i>pthread_create()</i>function will not return an error code of [EINTR].</blockquote><h4><a name = "tag_000_007_1320"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1321"> </a>APPLICATION USAGE</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1322"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_007_1323"> </a>SEE ALSO</h4><blockquote><i><a href="pthread_exit.html">pthread_exit()</a></i>,<i><a href="pthread_join.html">pthread_join()</a></i>,<i><a href="fork.html">fork()</a></i>,<i><a href="pthread.h.html"><pthread.h></a></i>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the POSIX Threads Extension (1003.1c-1995)</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -