프로그램

reentrant

고요한하늘... 2015. 4. 26. 22:08


In computing, a computer program or subroutine is called reentrant if it can be interrupted in the middle of its execution and then safely called again ("re-entered") before its previous invocations complete execution. 


The interruption could be caused by an internal action such as a jump or call, or by an external action such as a hardware interrupt or signal. once the reentered invocation completes, the previous invocations will resume correct execution.




컴퓨터상에서 컴퓨터 프로그램 또는 서브루틴은 프로그램 실행 중간에 인터럽트되었다가 호출시점의 상태로 완벽하게 복원할수 있을때 reentrant라고 부른다.


인터럽트는 하드웨어나 시그널고 괕은 외부 요인과 jump call과 같은 내부 요인에 의해 발생한다.




This definition originates from single-threaded programming environments where the flow of control could be interrupted by a hardware interrupt and transferred to an interrupt service routine (ISR). 


Any subroutine used by the ISR that could potentially have been executing when the interrupt was triggered should be reentrant. 


Often, subroutines accessible via the operating system kernel are not reentrant. 


Hence, interrupt service routines are limited in the actions they can perform; for instance, they are usually restricted from accessing the file system and sometimes even from allocating memory.


Reentrant의 정의는 싱글 쓰레드 프로그래밍 환경으로 하드웨어로와 ISR로 때문에 흐름제어가 중단되는 환경에서 유래되었다.


ISR에 의한 서브 루틴은 실행된 인터럽트가 reentrant일때만 잠재적으로 수행이 가능하다.


종종 OS 커널을 통해 접근된 서브루틴은 재진입가능하지 않다.


이런 이유로 ISR은 제한적으로 동작하게 된다. 예를 들면 파일 시스템을 접근할때나  할당된 메모리에서 조차 제한된다. 




A subroutine that is directly or indirectly recursive should be reentrant. This policy is partially enforced by structured programming languages.[citation needed] 


However a subroutine can fail to be reentrant if it relies on a global variable to remain unchanged but that variable is modified when the subroutine is recursively invoked.


그러나 서브루틴을


서브루틴은 직접, 간접적 재귀 될 때 reentrant 여야 한다.


이 정책은  구조적 프로그래밍 언어에 한해 강제 된다.


그러나 서브루틴은 변경되지 않고 남아 있는 전역변수에 의존하지만 서브루틴이 재귀적으로 호출될 때 변수가 수정되더라도 reentrant  실패할 수 있다.




This definition of reentrancy differs from that of thread-safety in multi-threaded environments. 


A reentrant subroutine can achieve thread-safety,[1] but being reentrant alone might not be sufficient to be thread-safe in all situations. Conversely, thread-safe code does not necessarily have to be reentrant (see below for examples).




재진입성의 정의는 multi-thread 환경에서의 thread-safety와는 다르다.


재진입 서브루틴은 thread-safety을 충족한다. 다만 모든 환경에서 thread-safe에 충분하지는 않다.


반대로 thread-safe 코드는 reentranct가 되기에 충분하지 않다.




'프로그램' 카테고리의 다른 글

linux vim color setting   (0) 2014.06.24
http protocol  (0) 2014.05.14
prefork  (0) 2014.05.14
hadoop to local-server  (0) 2014.01.03
malloc 2G 이상 메모리 할당  (0) 2013.11.15