pthread_getspecific(3p) - wariua/manpages-ko GitHub Wiki
μ΄ λ§€λ΄μΌ νμ΄μ§λ POSIX νλ‘κ·Έλλ¨Έ λ§€λ΄μΌμ μΌλΆμ΄λ€. μ΄ μΈν°νμ΄μ€μ 리λ μ€ κ΅¬νμ μ°¨μ΄κ° μμ μ μμΌλ©° (μμΈν 리λ μ€ λμ λ°©μμ ν΄λΉ 리λ μ€ λ§€λ΄μΌ νμ΄μ§ μ°Έκ³ ) 리λ μ€μμ μ΄ μΈν°νμ΄μ€κ° ꡬνλμ΄ μμ§ μμ μλ μλ€.
pthread_getspecific, pthread_setspecific - μ€λ λλ³ λ°μ΄ν° κ΄λ¦¬
#include <pthread.h>
void *pthread_getspecific(pthread_key_t key);
int pthread_setspecific(pthread_key_t key, const void *value);
pthread_getspecific()
ν¨μλ νμ¬ νΈμΆ μ€λ λμ λν΄μ μ§μ ν key
μ κ²°μλμ΄ μλ κ°μ λ°ννλ€.
pthread_setspecific()
ν¨μλ μμ pthread_key_create()
νΈμΆμ ν΅ν΄ μ»μ key
μ μ€λ λλ³ value
λ₯Ό μ°κ³νλ€. κ°μ ν€μ μ€λ λλ§λ€ λ€λ₯Έ κ°μ κ²°μν μ μλ€. λ³΄ν΅ κ·Έ κ°μ νΈμΆ μ€λ λμμ μ¬μ©νλ €κ³ μ€λΉν λμ ν λΉ λ©λͺ¨λ¦¬ λΈλ‘μ λν ν¬μΈν°μ΄λ€.
pthread_key_create()
λ‘ μ»μ κ²μ΄ μλ key
κ°μ λν΄μ, λλ pthread_key_delete()
λ‘ key
λ₯Ό μμ ν νμ pthread_getspecific()
μ΄λ pthread_setspecific()
μ νΈμΆνλ κ²°κ³Όλ κ·μ λμ΄ μμ§ μλ€.
pthread_getspecific()
κ³Ό pthread_setspecific()
λͺ¨λ μ€λ λλ³ λ°μ΄ν° μλ©Έμ ν¨μ λ΄μμ νΈμΆ κ°λ₯νλ€. μλ©Έ μ€μΈ μ€λ λλ³ λ°μ΄ν° ν€μ λν΄ pthread_getspecific()
μ νΈμΆνλ©΄ (μλ©Έμ μμ νμ) pthread_setspecific()
μΌλ‘ κ·Έ κ°μ λ°κΎΈμ§ μμλ€λ©΄ NULL κ°μ λ°ννλ€. μ€λ λλ³ λ°μ΄ν° μλ©Έμ λ£¨ν΄ λ΄μμ pthread_setspecific()
μ νΈμΆνλ κ²°κ³Όλ (μ΅μ PTHREAD_DESTRUCTOR_ITERATIONS
λ²μ μλ©Έ μλ ν) μ μ₯ κ° μ μ€μ΄λ 무ν 루νμΌ μ μλ€.
λ ν¨μ λͺ¨λ λ§€ν¬λ‘λ‘ κ΅¬νλμ΄ μμ μ μλ€.
pthread_getspecific()
ν¨μλ μ§μ ν key
μ μ°κ³λ μ€λ λλ³ λ°μ΄ν° κ°μ λ°ννλ€. key
μ μ°κ³λ μ€λ λλ³ λ°μ΄ν° κ°μ΄ μμΌλ©΄ NULL κ°μ λ°ννλ€.
μ±κ³΅ μ pthread_setspecific()
ν¨μλ 0μ λ°ννλ€. μλλ©΄ μ€λ₯λ₯Ό λνλ΄λ μ€λ₯ λ²νΈλ₯Ό λ°ννλ€.
pthread_getspecific()
μ μ΄λ€ μ€λ₯λ λ°ννμ§ μλλ€.
λ€μ κ²½μ°μ pthread_setspecific()
ν¨μκ° μ€ν¨νλ€.
ENOMEM
- NULL μλ κ°μ ν€μ μ°κ³νκΈ°μ μΆ©λΆν λ©λͺ¨λ¦¬κ° μλ€.
pthread_setspecific()
ν¨μλ μ€λ₯ μ½λ [EINTR]
μ λ°ννμ§ μλλ€.
μ΄νλ κ·λ²μ μ΄μ§ μμ λ΄μ©μ΄λ€.
μμ.
μμ.
μ€λ λλ³ λ°μ΄ν°μ μνλ₯Ό μ μ§νλ κΈ°λ₯λ€μλ pthread_getspecific()
μ μ±λ₯κ³Ό νΈμμ±μ΄ μμ£Ό μ€μνλ€. μ무μ μΌλ‘ νμ§ν΄μΌ νλ μ€λ₯κ° μμΌλ©° νμ§ν μ μμ μ μΌν μ€λ₯λ μ ν¨νμ§ μμ ν€ μ¬μ©λΏμ΄κΈ° λλ¬Έμ pthread_getspecific()
κΈ°λ₯μ μ€λ₯ λ³΄κ³ λ³΄λ€ μλμ λ¨μν¨μ μ νΈνλλ‘ μ€κ³λμ΄ μλ€.
pthread_setspecific()
μ key
μΈμλ‘ μ§μ ν κ°μ΄ pthread_key_create()
μΌλ‘ μ»μ ν€ κ°μ κ°λ¦¬ν€μ§ μκ±°λ pthread_key_delete()
λ‘ μμ λ ν€λ₯Ό κ°λ¦¬ν€κ³ μμμ ꡬνμμ κ°μ§νλ κ²½μ° ν¨μλ₯Ό μ€ν¨ μ²λ¦¬νκ³ [EINVAL]
μ€λ₯λ₯Ό λ³΄κ³ νκΈ°λ₯Ό κΆμ₯νλ€.
μμ.
POSIX.1-2008 Base Definitions κΆ, <pthread.h>
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2013