pthread_rwlock_rdlock(3p) - wariua/manpages-ko GitHub Wiki

PROLOG

이 맀뉴얼 νŽ˜μ΄μ§€λŠ” POSIX ν”„λ‘œκ·Έλž˜λ¨Έ λ§€λ‰΄μ–Όμ˜ 일뢀이닀. 이 μΈν„°νŽ˜μ΄μŠ€μ˜ λ¦¬λˆ…μŠ€ κ΅¬ν˜„μ— 차이가 μžˆμ„ 수 있으며 (μƒμ„Έν•œ λ¦¬λˆ…μŠ€ λ™μž‘ 방식은 ν•΄λ‹Ή λ¦¬λˆ…μŠ€ 맀뉴얼 νŽ˜μ΄μ§€ μ°Έκ³ ) λ¦¬λˆ…μŠ€μ—μ„œ 이 μΈν„°νŽ˜μ΄μŠ€κ°€ κ΅¬ν˜„λ˜μ–΄ μžˆμ§€ μ•Šμ„ μˆ˜λ„ μžˆλ‹€.

NAME

pthread_rwlock_rdlock, pthread_rwlock_tryrdlock - 읽기-μ“°κΈ° 락 객체λ₯Ό 읽기용으둜 잠그기

SYNOPSIS

#include <pthread.h>

int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);

DESCRIPTION

pthread_rwlock_rdlock() ν•¨μˆ˜λŠ” rwlock이 κ°€λ¦¬ν‚€λŠ” 읽기-μ“°κΈ° 락에 읽기 락을 μ μš©ν•œλ‹€. μ“°κΈ° μͺ½μ΄ 락을 작고 μžˆμ§€ μ•Šκ³  락에 블둝 된 μ“°κΈ° μͺ½μ΄ μ—†μœΌλ©΄ 호좜 μŠ€λ ˆλ“œκ°€ 읽기 락을 νšλ“ν•œλ‹€.

Thread Execution Scheduling μ˜΅μ…˜μ„ μ§€μ›ν•˜λ©° 락에 κ΄€λ ¨λœ μŠ€λ ˆλ“œλ“€μ΄ μŠ€μΌ€μ€„λ§ μ •μ±… SCHED_FIFOλ‚˜ SCHED_RR둜 μ‹€ν–‰ 쀑인 경우, μ“°κΈ° μͺ½μ΄ 락을 작고 μžˆκ±°λ‚˜ 더 λ†’κ±°λ‚˜ 같은 μš°μ„ μˆœμœ„μ˜ μ“°κΈ° μͺ½μ΄ 락에 블둝 λ˜μ–΄ 있으면 호좜 μŠ€λ ˆλ“œκ°€ 락을 νšλ“ν•˜μ§€ μ•ŠλŠ”λ‹€. μ•„λ‹ˆλ©΄ 호좜 μŠ€λ ˆλ“œκ°€ 락을 νšλ“ν•œλ‹€.

Thread Execution Scheduling μ˜΅μ…˜μ„ μ§€μ›ν•˜λ©° 락에 κ΄€λ ¨λœ μŠ€λ ˆλ“œλ“€μ΄ μŠ€μΌ€μ€„λ§ μ •μ±… SCHED_SPORADIC으둜 μ‹€ν–‰ 쀑인 경우, μ“°κΈ° μͺ½μ΄ 락을 작고 μžˆκ±°λ‚˜ 더 λ†’κ±°λ‚˜ 같은 μš°μ„ μˆœμœ„μ˜ μ“°κΈ° μͺ½μ΄ 락에 블둝 λ˜μ–΄ 있으면 호좜 μŠ€λ ˆλ“œκ°€ 락을 νšλ“ν•˜μ§€ μ•ŠλŠ”λ‹€. μ•„λ‹ˆλ©΄ 호좜 μŠ€λ ˆλ“œκ°€ 락을 νšλ“ν•œλ‹€.

Thread Execution Scheduling μ˜΅μ…˜μ„ μ§€μ›ν•˜μ§€ μ•ŠλŠ” 경우, μ“°κΈ° μͺ½μ΄ 락을 작고 μžˆμ§€ μ•Šκ³  락에 블둝 된 μ“°κΈ° μͺ½μ΄ μžˆμ„ λ•Œ 호좜 μŠ€λ ˆλ“œκ°€ 락을 νšλ“ν•˜λŠ”μ§€ μ—¬λΆ€λŠ” κ΅¬ν˜„μ—μ„œ κ·œμ •ν•œλ‹€. μ“°κΈ° μͺ½μ΄ 락을 작고 있으면 호좜 μŠ€λ ˆλ“œκ°€ 읽기 락을 νšλ“ν•˜μ§€ μ•ŠλŠ”λ‹€. 읽기 락을 νšλ“ν•˜μ§€ μ•ŠλŠ” 경우 호좜 μŠ€λ ˆλ“œλŠ” 락을 νšλ“ν•  수 있게 될 λ•ŒκΉŒμ§€ 블둝 ν•œλ‹€. 호좜이 μ΄λ€„μ§€λŠ” μ‹œμ μ— 호좜 μŠ€λ ˆλ“œκ°€ μ“°κΈ° 락을 작고 μžˆλ‹€λ©΄ ꡐ착이 일어날 μˆ˜λ„ μžˆλ‹€.

ν•œ μŠ€λ ˆλ“œμ—μ„œ rwlock에 λ™μ‹œμ— 읽기 락을 μ—¬λŸ¬ 개 작고 μžˆμ„ μˆ˜λ„ (즉 pthread_rwlock_rdlock() ν•¨μˆ˜λ₯Ό n번 μ„±κ³΅μ μœΌλ‘œ ν˜ΈμΆœν•  수) μžˆλ‹€. 그런 κ²½μš°μ— μ‘μš©μ—μ„œλŠ” κ·Έ μŠ€λ ˆλ“œκ°€ λŒ€μ‘ν•˜λŠ” ν’€κΈ°λ₯Ό μˆ˜ν–‰ν•˜λ„λ‘ (즉 pthread_rwlock_unlock() ν•¨μˆ˜λ₯Ό n번 ν˜ΈμΆœν•˜λ„λ‘) ν•΄μ•Ό ν•œλ‹€.

κ΅¬ν˜„μ—μ„œ 읽기-μ“°κΈ° 락에 적용 κ°€λŠ₯ν•˜λ‹€κ³  보μž₯ν•˜λŠ” λ™μ‹œ 읽기 락 μ΅œλŒ€ μˆ˜λŠ” κ΅¬ν˜„μ—μ„œ κ·œμ •ν•œλ‹€. κ·Έ μ΅œλŒ“κ°’μ„ μ΄ˆκ³Όν•˜κ²Œ λ˜λŠ” 경우 pthread_rwlock_rdlock() ν•¨μˆ˜κ°€ μ‹€νŒ¨ν•  μˆ˜λ„ μžˆλ‹€.

pthread_rwlock_tryrdlock() ν•¨μˆ˜λŠ” pthread_rwlock_rdlock() ν•¨μˆ˜μ²˜λŸΌ 읽기 락을 μ μš©ν•˜λ˜ λ™λ“±ν•œ pthread_rwlock_rdlock() 호좜이 호좜 μŠ€λ ˆλ“œλ₯Ό 블둝 μ‹œν‚€κ²Œ 될 κ²½μš°μ— ν•¨μˆ˜κ°€ μ‹€νŒ¨ν•˜κ²Œ λœλ‹€. μ–΄λ–€ κ²½μš°μ—λ„ pthread_rwlock_tryrdlock() ν•¨μˆ˜λŠ” μ ˆλŒ€ 블둝 ν•˜μ§€ μ•ŠλŠ”λ‹€. 락을 νšλ“ν•˜κ±°λ‚˜ μ‹€νŒ¨ν•˜κ³  μ¦‰μ‹œ λ°˜ν™˜ν•œλ‹€.

μ΄ˆκΈ°ν™” μ•ˆ 된 읽기-μ“°κΈ° 락으둜 이 ν•¨μˆ˜λ“€μ„ ν˜ΈμΆœν•˜λŠ” 경우의 κ²°κ³ΌλŠ” κ·œμ •λ˜μ–΄ μžˆμ§€ μ•Šλ‹€.

읽기-μ“°κΈ° 락에 읽기용으둜 λŒ€κΈ° 쀑인 μŠ€λ ˆλ“œμ—κ²Œ μ‹œκ·Έλ„μ΄ μ „λ‹¬λ˜λŠ” 경우 μ‹œκ·Έλ„ ν•Έλ“€λŸ¬μ—μ„œ λ°˜ν™˜ν•œ μŠ€λ ˆλ“œκ°€ μ€‘λ‹¨λœ 적 μ—†λŠ” κ²ƒμ²˜λŸΌ λ‹€μ‹œ 읽기-μ“°κΈ° 락에 읽기용으둜 λŒ€κΈ°ν•œλ‹€.

RETURN VALUE

성곡 μ‹œ pthread_rwlock_rdlock() ν•¨μˆ˜λŠ” 0을 λ°˜ν™˜ν•œλ‹€. μ•„λ‹ˆλ©΄ 였λ₯˜λ₯Ό λ‚˜νƒ€λ‚΄λŠ” 였λ₯˜ 번호λ₯Ό λ°˜ν™˜ν•œλ‹€.

pthread_rwlock_tryrdlock() ν•¨μˆ˜λŠ” rwlock이 κ°€λ¦¬ν‚€λŠ” 읽기-μ“°κΈ° 락 κ°μ²΄μ—μ„œ 읽기용 락을 νšλ“ν•œ 경우 0을 λ°˜ν™˜ν•œλ‹€. μ•„λ‹ˆλ©΄ 였λ₯˜λ₯Ό λ‚˜νƒ€λ‚΄λŠ” 였λ₯˜ 번호λ₯Ό λ°˜ν™˜ν•œλ‹€.

ERRORS

λ‹€μŒ κ²½μš°μ— pthread_rwlock_tryrdlock() ν•¨μˆ˜κ°€ μ‹€νŒ¨ν•œλ‹€.

EBUSY
μ“°κΈ° μͺ½μ΄ 락을 작고 μžˆκ±°λ‚˜ μ μ ˆν•œ μš°μ„ μˆœμœ„μ˜ μ“°κΈ° μͺ½μ΄ 락에 블둝 λ˜μ–΄ μžˆμ–΄μ„œ 읽기-μ“°κΈ° 락을 νšλ“ν•  수 μ—†λ‹€.

λ‹€μŒ κ²½μš°μ— pthread_rwlock_rdlock() 및 pthread_rwlock_tryrdlock() ν•¨μˆ˜κ°€ μ‹€νŒ¨ν•  μˆ˜λ„ μžˆλ‹€.

EAGAIN
rwlock에 λŒ€ν•œ 읽기 락 μ΅œλŒ€ 횟수λ₯Ό μ΄ˆκ³Όν–ˆκΈ° λ•Œλ¬Έμ— 읽기 락을 νšλ“ν•  수 μ—†λ‹€.

λ‹€μŒ κ²½μš°μ— pthread_rwlock_rdlock() ν•¨μˆ˜κ°€ μ‹€νŒ¨ν•  μˆ˜λ„ μžˆλ‹€.

EDEADLK
ꡐ착 쑰건을 νƒμ§€ν–ˆκ±°λ‚˜ ν˜„μž¬ μŠ€λ ˆλ“œκ°€ 이미 κ·Έ 읽기-μ“°κΈ° 락을 μ“°κΈ°μš©μœΌλ‘œ κ°€μ§€κ³  μžˆλ‹€.

이 ν•¨μˆ˜λ“€μ€ 였λ₯˜ μ½”λ“œ [EINTR]을 λ°˜ν™˜ν•˜μ§€ μ•ŠλŠ”λ‹€.

μ΄ν•˜λŠ” κ·œλ²”μ μ΄μ§€ μ•Šμ€ λ‚΄μš©μ΄λ‹€.

EXAMPLES

μ—†μŒ.

APPLICATION USAGE

이 ν•¨μˆ˜λ“€μ„ μ“°λŠ” μ‘μš©μ—μ„œ POSIX.1-2008 Base Definitions ꢌ의 3.287절 Priority Inversionμ—μ„œ λ…Όμ˜ν•˜λŠ” μš°μ„ μˆœμœ„ 역전을 κ²ͺ을 수 μžˆλ‹€.

RATIONALE

pthread_rwlock_rdlock()μ΄λ‚˜ pthread_rwlock_tryrdlock()의 rwlock 인자둜 μ§€μ •ν•œ 값이 μ΄ˆκΈ°ν™” 된 읽기-μ“°κΈ° 락 객체λ₯Ό 가리킀고 μžˆμ§€ μ•ŠμŒμ„ κ΅¬ν˜„μ—μ„œ κ°μ§€ν•˜λŠ” 경우 ν•¨μˆ˜λ₯Ό μ‹€νŒ¨ μ²˜λ¦¬ν•˜κ³  [EINVAL] 였λ₯˜λ₯Ό λ³΄κ³ ν•˜κΈ°λ₯Ό ꢌμž₯ν•œλ‹€.

FUTURE DIRECTIONS

μ—†μŒ.

SEE ALSO

pthread_rwlock_destroy(), pthread_rwlock_timedrdlock(), pthread_rwlock_timedwrlock(), pthread_rwlock_trywrlock(), pthread_rwlock_unlock()

POSIX.1-2008 Base Definitions ꢌ, 3.287절 Priority Inversion, 4.11절 Memory Synchronization, <pthread.h>

COPYRIGHT

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

⚠️ **GitHub.com Fallback** ⚠️