.\" Copyright (c) 1996 John Birrell . .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by John Birrell. .\" 4. Neither the name of the author nor the names of any co-contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" %FreeBSD: src/lib/libc_r/man/pthread_create. 3, v 1.9. 2.5 2001/12/17 10:08:26 ru Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man3/pthread_create. 3, v 1.6 2002/05/18 07:12:56 horikawa Exp $ .Dd April 4, 1996 .Dt PTHREAD_CREATE 3 .Os .Sh ¸íĪ .Nm pthread_create .Nd »õ·Î¿î threadÀÇ ÀÛ¼º .Sh ÇÁ·Î±×·¥ ¶óÀ̺귯¸® .Lb libc_r .Sh ¼­½Ä .In pthread.h .Ft int .Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" .Sh ÇØ¼³ .Fn pthread_create ÇÔ¼ö´Â, ÇÁ·Î¼¼½º³»¿¡ .Fa attr ¿¡ ÀÇÇØ ÁöÁ¤µÈ ¼Ó¼ºÀ» °¡Áö´Â »õ·Î¿î thread¸¦ ÀÛ¼ºÇϱâ À§Çؼ­ »ç¿ëµË´Ï´Ù. .Fa attr ÇÏÁö¸¸ .Dv NULL ÀÎ °æ¿ì¿¡´Â, µðÆúÆ®ÀÇ ¼Ó¼ºÀÌ »ç¿ëµË´Ï´Ù. .Fa attr ¿¡ ÀÇÇØ ÁöÁ¤µÈ ¼Ó¼ºÀÌ ³ªÁß¿¡ °»½ÅµÇ¾úÀ» °æ¿ì¿¡´Â, threadÀÇ ¼Ó¼ºÀº º¯È­ÇÏÁö ¾Ê½À´Ï´Ù. ¹®Á¦ ¾ø°Ô ¿Ï·áÇϸé(ÀÚ), .Fn pthread_create ÇÏ .Fa thread ¿¡ ÀÇÇØ ÁöÁ¤µÈ Àå¼Ò¿¡ ÀÛ¼ºµÈ threadÀÇ ID ¸¦ °Ý³³ÇÕ´Ï´Ù. .Pp thread´Â, .Fa arg (À»)¸¦ À¯ÀÏÇÑ Àμö·Î¼­ .Fa start_routine (À»)¸¦ ½ÇÇàÇÏ´Â °ÍÀ¸·Î ÀÛ¼ºµË´Ï´Ù. .Fa start_routine ÇÏÁö¸¸ µ¹¾Æ¿ÔÀ» °æ¿ì¿¡´Â, .Fa start_routine ÀÇ ¹Ýȯ°ªÀ» Á¾·á ½ºÅ×ÀÌÅͽº·Î¼­ »ç¿ëÇØ, ¾Ï¹¬Áß¿¡ .Fn pthread_exit (À»)¸¦ È£ÃâÇÑ °Í °°Àº È¿°ú°¡ ÀÖ½À´Ï´Ù. .Fn main (À»)¸¦ ÃÖÃʷο¡ ½ÇÇàÇÑ thread´Â, À̰Ͱú´Â ´Ù¸¥ °Í¿¡ ÁÖÀÇÇØ ÁÖ¼¼¿ä. ±× thread°¡ .Fn main (À¸)·ÎºÎÅÍ µ¹¾Æ¿ÔÀ» ¶§¿¡´Â, .Fn main ÀÇ ¹Ýȯ°ªÀ» Á¾·á ½ºÅ×ÀÌÅͽº·Î¼­ »ç¿ëÇØ, ¾Ï¹¬Áß¿¡ .Fn exit (À»)¸¦ È£ÃâÇÑ °Í °°Àº È¿°ú°¡ ÀÖ½À´Ï´Ù. .Pp »õ·Î¿î threadÀÇ ½Ã±×³Î »óÅ´Â, ÀÌÇÏ¿Í °°ÀÌ ÃʱâÈ­µË´Ï´Ù. .Bl -bullet -offset indent .It ½Ã±×³Î ¸¶½ºÅ©´Â ÀÛ¼ºÇÑ thread·ÎºÎÅÍ °è½ÂµË´Ï´Ù. .It »õ·Î¿î thread¿ëÀ¸·Î º¸·ùÇϰí ÀÖ´Â ½Ã±×³Î¼¼Æ®´Â ÇÏ´ÃÀÔ´Ï´Ù. .El .Sh ¹Ýȯ°ª ¹®Á¦°¡ ¾ø´Â °æ¿ì´Â, .Fn pthread_create ÇÔ¼ö´Â 0 À» µ¹·ÁÁÝ´Ï´Ù. ¹®Á¦°¡ ÀÖ´Â °æ¿ì´Â, ±× ¿¡·¯¸¦ ³ªÅ¸³»±â À§Çؼ­(¶§¹®¿¡) ¿¡·¯ ¹øÈ£°¡ µ¹·ÁÁÖ¾îÁý´Ï´Ù. .Sh ¿¡·¯ .Fn pthread_create (Àº)´Â ÀÌÇÏÀÇ °æ¿ì¿¡ ½ÇÆÐÇÕ´Ï´Ù. .Bl -tag -width Er .It Bq Er EAGAIN ´Ù¸¥ thread¸¦ ÀÛ¼ºÇϱâ À§Çؼ­ ÇÊ¿äÇÑ ¸®¼Ò½º°¡ ½Ã½ºÅÛ¿¡ ºÎÁ·ÇÕ´Ï´Ù. ¶Ç´Â, 1 °³ÀÇ ÇÁ·Î¼¼½º³»ÀÇ ÃÑthread¼ö¿¡ ´ëÇÑ ½Ã½ºÅÛÀÇ Á¦ÇÑ [PTHREAD_THREADS_MAX] ¸¦ ÃʰúÇß½À´Ï´Ù. .It Bq Er EINVAL .Fa attr ¿¡ ÀÇÇØ ÁöÁ¤µÈ °ªÀÌ, À¯È¿ÇÏÁö´Â ¾Ê½À´Ï´Ù. .El .Pp .Sh °ü·Ã Ç׸ñ .Xr fork 2 , .Xr pthread_cleanup_pop 3 , .Xr pthread_cleanup_push 3 , .Xr pthread_exit 3 , .Xr pthread_join 3 .Sh Ç¥ÁØ .Fn pthread_create ÇÏ .St -p1003.1-96 ¿¡ ÀûÇÕÇϰí ÀÖ½À´Ï´Ù.