.\" 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_key_create. 3, v 1.6. 2.5 2001/12/17 10:08:26 ru Exp % .\" .\" $FreeBSD: doc/ja_JP.eucJP/man/man3/pthread_key_create. 3, v 1.5 2002/05/18 07:12:56 horikawa Exp $ .Dd April 4, 1996 .Dt PTHREAD_KEY_CREATE 3 .Os .Sh ¸íĪ .Nm pthread_key_create .Nd thread °íÀ¯ÀÇ µ¥ÀÌÅÍ Å°ÀÇ ÀÛ¼º .Sh ÇÁ·Î±×·¥ ¶óÀ̺귯¸® .Lb libc_r .Sh ¼­½Ä .In pthread.h .Ft int .Fn pthread_key_create "pthread_key_t *key" "void (*destructor)(void *)" .Sh ÇØ¼³ .Fn pthread_key_create ÇÔ¼ö´Â, ÇÁ·Î¼¼½º³»ÀÇ ¸ðµç thread¿¡ °¡½ÃÀÇ thread °íÀ¯ÀÇ µ¥ÀÌÅÍ Å°¸¦ ÀÛ¼ºÇÕ´Ï´Ù. .Fn pthread_key_create ¿¡ ÀÇÇØ Á¦°øµÈ ŰÀÇ °ªÀº, thread °íÀ¯ÀÇ µ¥ÀÌÅÍÀÇ À§Ä¡¸¦ ³ªÅ¸³»±â À§Çؼ­(¶§¹®¿¡) »ç¿ëµÇ´Â ºÒÅõ¸íÇÑ ¿ÀºêÁ§Æ®ÀÔ´Ï´Ù. ´Ù¸¥ thread¿¡ ÀÇÇØ °°Àº Űġ°¡ »ç¿ëµÇ´Â °ÍÀÌ °¡´ÉÇÕ´Ï´Ù¸¸, .Fn pthread_setspecific ¿¡ ÀÇÇØ Ű¿¡ ¹­À» ¼ö ÀÖ¾ú´ø °ªÀº thread¸¶´Ù¸¦ ±âÁØ¿¡ ¸ÞÀÎÆ®³Í½ºµÇ¾î È£ÃâÇϰí ÀÖ´Â thread°¡ »ì¾Æ ÀÖ´Â µ¿¾È Á¸¼ÓÇÕ´Ï´Ù. .Pp ŰÀÇ ÀÛ¼º½Ã¿¡´Â, ¸ðµç ¾×ƼºêÇÑ thread³»ÀÇ »õ·Î¿î Ű¿¡, °ª NULL °¡ °ü·ÃÁöÀ» ¼ö ÀÖ½À´Ï´Ù. threadÀÇ ÀÛ¼º½Ã¿¡´Â, »õ·Î¿î thread³»ÀÇ ¸ðµç Á¤ÀÇÁ¦ÀÇ Å°¿¡, °ª NULL °¡ °ü·ÃÁöÀ» ¼ö ÀÖ½À´Ï´Ù. .Pp ÀÓÀÇÀÇ ¼Ò¸êÀÚ ÇÔ¼ö´Â, °³°³ÀÇ Å°ÀÇ °ª°ú °ü·ÃÁöÀ» ¼ö ÀÖÀ» ¼ö°¡ ÀÖ½À´Ï´Ù. threadÀÇ Á¾·á½Ã¿¡, Űġ°¡ NULL °¡ ¾Æ´Ñ ¼Ò¸êÀÚÀÇ Æ÷ÀÎÅ͸¦ °¡Á®, ÇÑÆí thread¸¦ Ű¿¡ °ü·ÃÁöÀ» ¼ö ÀÖ¾ú´ø NULL °¡ ¾Æ´Ñ °ªÀ» °¡Áö°í ÀÖ´Â °æ¿ì¿¡´Â, ÇöÀç °ü·ÃÁöÀ» ¼ö ÀÖ°í ÀÖ´Â °ªÀ» À¯ÀÏÇÑ Àμö·Î¼­ °¡¸®ÄÑÁö°í ÀÖ´Â ÇÔ¼ö°¡ ºÒ·Á °©´Ï´Ù. threadÀÇ Á¾·á½Ã¿¡ ±× thread¸¦ À§ÇÑ 1 °³ ÀÌ»óÀÇ ¼Ò¸êÀÚ ÇÔ¼ö°¡ Á¸ÀçÇÏ´Â °æ¿ì¿¡´Â, ¼Ò¸êÀÚÀÇ È£ÃâÀÇ ¼ø¼­´Â ¹Ì±ÔÁ¤ÀÔ´Ï´Ù. .Pp ¼Ò¸êÀÚ¿¡ °ü·ÃÁöÀ» ¼ö ÀÖ´ø ¸ðµç NULL °¡ ¾Æ´Ñ °ªÀ» À§Çؼ­(¶§¹®¿¡), ¸ðµç ¼Ò¸êÀÚ°¡ ºÒ·Á °£ ´ÙÀ½¿¡, ¾ÆÁ÷ ¸î°³ÀÇ °ü·ÃÁöÀ» ¼ö ÀÖ¾ú´ø ¼Ò¸êÀÚ¸¦ °¡Áö´Â NULL °¡ ¾Æ´Ñ °ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â, ±× °úÁ¤ÀÌ ¹Ýº¹ÇØÁý´Ï´Ù. ÃÖ¾ÇÀ̾ [PTHREAD_DESTRUCTOR_ITERATIONS] ȸÀÇ ¼Ò¸êÀÚÀÇ È£ÃâÀÇ ¹Ýº¹ÀÇ ÈÄ¿¡, ¾ÆÁ÷ ´õ ¸î°³ÀÇ °ü·ÃÁöÀ» ¼ö ÀÖ¾ú´ø ¼Ò¸êÀÚ¸¦ °¡Áö´Â NULL °¡ ¾Æ´Ñ °ªÀÌ ÀÖ´Â °æ¿ì¿¡´Â, ½ÇÀåÀº ¼Ò¸êÀÚÀÇ È£ÃâÀ» ÁßÁöÇÕ´Ï´Ù. .Sh ¹Ýȯ°ª ¹®Á¦°¡ ¾ø´Â °æ¿ì´Â, .Fn pthread_key_create ÇÔ¼ö´Â, »õ·Ó°Ô ÀÛ¼ºµÈ ŰÀÇ °ªÀ» .Fa key ±×¸®°í ÁöÁ¤µÈ Àå¼Ò¿¡ °Ý³³ÇØ, 0 À» µ¹·ÁÁÝ´Ï´Ù. ¹®Á¦°¡ ÀÖ´Â °æ¿ì´Â, ±× ¿¡·¯¸¦ ³ªÅ¸³»±â À§Çؼ­(¶§¹®¿¡) ¿¡·¯ ¹øÈ£°¡ µ¹·ÁÁÖ¾îÁý´Ï´Ù. .Sh ¿¡·¯ .Fn pthread_key_create (Àº)´Â ÀÌÇÏÀÇ °æ¿ì¿¡ ½ÇÆÐÇÕ´Ï´Ù. .Bl -tag -width Er .It Bq Er EAGAIN ´Ù¸¥ thread °íÀ¯ÀÇ µ¥ÀÌÅÍ Å°¸¦ ÀÛ¼ºÇϱâ À§Çؼ­ ÇÊ¿äÇÑ ¸®¼Ò½º°¡ ½Ã½ºÅÛ¿¡ ºÎÁ·ÇÕ´Ï´Ù. ¶Ç´Â, 1 °³ÀÇ ÇÁ·Î¼¼½º¸¶´ÙÀÇ Å°ÀÇ ÃѼö¿¡ ´ëÇÑ ½Ã½ºÅÛÀÇ Á¦ÇÑ [PTHREAD_KEYS_MAX] ¸¦ ÃʰúÇß½À´Ï´Ù. .It Bq Er ENOMEM ۸¦ ÀÛ¼ºÇϱâ À§ÇÑ ÃæºÐÇÑ ¸Þ¸ð¸®°¡ ¾ø½À´Ï´Ù. .El .Sh °ü·Ã Ç׸ñ .Xr pthread_getspecific 3 , .Xr pthread_key_delete 3 , .Xr pthread_setspecific 3 .Sh Ç¥ÁØ .Fn pthread_key_create ÇÏ .St -p1003.1-96 ¿¡ ÀûÇÕÇϰí ÀÖ½À´Ï´Ù.