티스토리 뷰
Reentrant
From Wikipedia, the free encyclopedia
- For other uses of the term, see Reentrant (disambiguation)
A computer program or routine is described as reentrant if it can be safely executed concurrently; that is, the routine can be re-entered while it is already running. To be reentrant, a function must:
- Hold no static (global) non-constant data.
- Must not return the address to static (global) non-constant data.
- Must work only on the data provided to it by the caller.
- Must not rely on locks to singleton resources.
- Must not call non-reentrant functions.
Multiple levels of 'user/object/process priority' and/or multiprocessing usually complicate the control of reentrant code. Also, IO code is usually not reentrant because it relies on shared, singleton resources such as disks.
Reentrancy is a key feature of functional programming.
Contents[hide] |
[edit] Examples
In the following piece of C code, neither functions f
nor g
are reentrant.
int g_var = 1; int f() { return g_var + 2; } int g() { return f() + 2; } int main() { g(); return 0; }
In the above, f
depends on a global variable g_var; thus, if two threads execute it and access g_var concurrently, then the result varies depending on the timing of the execution. Hence, f is not reentrant. Neither is g
; it calls f
, which is not reentrant.
These slightly-altered versions are reentrant:
int f(int i) { return i + 2; } int g(int i) { return f(i) + 2; } int main() { g(1); return 0; }
[edit] Relation to thread-safety
Reentrance and thread-safety are separate concepts: a function can be reentrant, thread-safe, both, or neither. However, both these concepts are related to the way functions handle resources.
A thread-safe function protects shared resources from concurrent access by locks. Thread-safety concerns only the implementation of a function and does not affect its external interface. In case of reentrancy, the external interface itself should be such that all data is provided by the caller of the function.
In most cases, to make a non-reentrant function reentrant, it must be replaced by a function with a modified interface. To make a thread-unsafe function thread-safe, only the implementation needs to be changed, usually by adding synchronization blocks.
Non-reentrant functions are not thread-safe. Furthermore, it may be impossible to make a non-reentrant function thread-safe.
[edit] See also
[edit] External links
- Article "Use reentrant functions for safer signal handling" by Dipak K Jha
- "Writing Reentrant and Thread-Safe Code," from AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs, 2nd edition, 1999.
'IT > OS' 카테고리의 다른 글
RealTek HD Audio 드라이버 문제 해결 (HD Audio Error) [펌 imarket.tistory.com] (1) | 2007.12.19 |
---|---|
Reentrant - (0) | 2007.12.18 |
rsync 대여폭 제한 (0) | 2007.07.06 |
rsync 를 이용한 서버간의 동기화 및 백업 (0) | 2007.07.06 |
운영체제별 명령어비교표 (0) | 2007.07.06 |
- Total
- Today
- Yesterday
- 지루박멸연구센타
- 열정의 힘을 믿는다
- Le4rN TO Cr4cK
- 디버깅에관한모든것(DebugLab)
- sysinternals
- FoundStone
- hashtab
- 보안-coderant
- 디바이스드라이버 개발자 포럼
- dualpage.muz.ro
- osronline.com - 드라이버 관련 정보 사이트
- NtInternals - NativeAPI Refere…
- pcthreat - spyware 정보 제공
- rootkit.com - 루트킷 관련 정보
- www.ntinternals.net
- WINE CrossRef. - source.winehq…
- tuts4you
- hex-rays
- idapalace
- idefense
- immunityinc
- threatexpert
- hdp.null2root.org
- www.crackstore.com
- crackmes.de
- www.who.is
- www.cracklab.ru
- community.reverse-engineering.…
- video.reverse-engineering.net
- SnD
- 클레이 키위
- reversengineering.wordpress.co…
- www.openrce.org
- www.woodmann.com
- PEID.Plusins.BobSoft
- roxik.com/pictaps/
- regexlib.com
- spyware-browser.com
- www.usboffice.kr
- regulator
- www.txt2re.com
- ietab.mozdev.org
- zesrever.xstone.org
- www.heaventools.com/PE-file-he…
- www.heaventools.com
- www.innomp3.com
- 울지않는벌새
- exetools.com-forum
- exetools.com
- utf8 conv
- robtex - IP trace
- onsamehost - same IP sites
- JpopSuki
- jsunpack.jeek.org
- wepawet.iseclab.org
- www.jswiff.com
- www.hackeroo.com
- winesearcher.co.kr
- khpga.org
- malwareurl.com
- anubis.iseclab.org
- www.crummy.com-eautifulSoup
- malwarebytes.org/forums
- bbs.janmeng.com
- blackip.ustc.edu.cn
- eureka.cyber-ta.org
- exploit-db.com
- ElasticSearch
- 신한저축은행
- PIR
- 미국주식
- INVOICE
- ubuntu
- O365
- 주식
- 다올저축은행
- 실시간트래이딩
- 사회간접자본
- 전세매매지수
- 자동트래이딩
- 매매가격지수
- SBI저축은행
- 공공인프라
- 시스템트래이딩
- ChatGPT
- ROA
- 주식트래이딩
- 맥쿼리인프라
- systemd
- logrotate
- 주택구매력지수
- 레고랜드
- 피봇
- Pivot
- 군함도
- CriticalSection
- hai
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |