-
Notifications
You must be signed in to change notification settings - Fork 19
[c] re entrancy and thread safty
Myungchul Shin edited this page Apr 24, 2015
·
6 revisions
-
reentrancy
- "A function is
reentrant
if it can be invoked while already in the process of executing. That is, a function is reentrant if it can be interrupted in the middle of execution (for example, by a signal or interrupt) and invoked again before the interrupted execution completes." - "A reentrant function can be
invoked, interrupted, and re-invoked
. Such a function can be invoked simultaneously by multiple threads if and only if each invocation references or provides unique data and inputs." - "The term reentrancy predates threads and is often used only in a
single threaded context
, for example when discussing if a function is signal or interrupt-safe." - reentrancy는 기본적으로 single thread에서 논의되는 개념이다. function의 실행 도중에 signal이나 interrupt를 받아 중지되었을 때, 다시 재개(re-enter)해도 동일한 결과를 보장하는가? 그리고 이 개념을 multi thread 환경으로 확장한다고 해도 마찬가지여야 한다.
- "A function is
-
thread-safty
- "A
thread-safe
function can be invoked simultaneously by multiple threads, even if each invocation references or provides the same data or input, as all access is serialized." - tread-safty는 여러개의 thread가 동시에 function을 실행시켜도 동기화 문제가 없다는 개념이다.
- "a thread-safe function that achieves safety through a mutex is
potentially not reentrant
, as the interruption could deadlock on the already-acquired mutex." - function이 mutex 등을 통해서 동기화하기 때문에 thread-safe하다고 해도, 잠재적으로 reentrant하지는 않다
- "A