메모리 모델(프로그래밍)
Memory model (programming)컴퓨팅에서 메모리 모델은 메모리를 통한 스레드의 상호작용과 데이터의 공유 사용을 설명한다.
역사와 의의
메모리 모델은 컴파일러가 많은 중요한 최적화를 수행할 수 있도록 한다.프로그램의 루프 융접 이동 문과 같은 컴파일러 최적화는 잠재적으로 공유된 변수의 읽기 및 쓰기 작업 순서에 영향을 미칠 수 있다.읽기 및 쓰기 순서의 변경은 레이스 상태를 유발할 수 있다.메모리 모델이 없으면 컴파일러는 일반적으로 멀티스레드 프로그램에 이러한 최적화를 적용할 수 없으며, 특별한 경우에만 해당 최적화를 적용할 수 없다.또는 일부 컴파일러의 경우 멀티스레딩과 호환되지 않는 최적화를 초래할 수 있는 멀티스레딩 실행(그래서 더 나은 최적화된 코드가 생성될 수 없음)이 없다고 가정할 수 있으며, 이는 종종 초기 테스트에서 나타나지 않는 미묘한 버그를 초래할 수 있다.
따라서 자바와 같은 현대 프로그래밍 언어는 메모리 모델을 구현한다.메모리 모델은 동기화된 블록이나 메서드를 입력하여 잠금을 획득하는 것과 같이 특수하고 잘 정의된 동기화 연산을 통해 설정된 동기화 장벽을 지정한다.메모리 모델은 그러한 동기화 장벽에 도달할 때에만 공유 변수의 값을 변경할 필요가 있다고 규정한다.더욱이, 경기 조건의 전체 개념은 이러한 기억 장벽과 관련하여 운영 순서에 따라 정의된다.[1]
그러면 이러한 의미론은 최적화를 적용할 때 컴파일러에게 더 높은 자유도를 준다: 컴파일러는 동기화 장벽에서 (잠재적으로 공유되는) 변수의 값이 최적화 코드와 최적화되지 않은 코드 모두에서 동일하도록 보장만 하면 된다.특히, 동기화 장벽을 포함하지 않는 코드 블록에서 문장의 순서를 변경하는 것은 컴파일러에 의해 안전하다고 가정한다.
메모리 모델 분야에서 대부분의 연구는 다음과 같이 진행된다.
- 컴파일러 최적화를 위한 최대 자유도를 제공하는 동시에 무경주 및 (아마도 더 중요한) 경주 포함 프로그램에 대한 충분한 보증을 제공하는 메모리 모델 설계.
- 이러한 메모리 모델에 대해 올바른 프로그램 최적화 입증.
Java Memory Model은 인기 있는 프로그래밍 언어에 포괄적인 스레딩 메모리 모델을 제공하는 첫 번째 시도였다.[2]이후에, 스레드 안전하게 도서관으로 구현에 대한 확실한 제한 없이 구현할 수 없었던 설립되었다 특히에서(99과 C++03)C++에 실을 꿰분과 위원회 적합한 메모리 모델을 개발하기 시작해 필요한 restrictions,[3][4]이 부족한 C와 C++표준;2005년에 그들은 C작업 의사를 제출했다.ument그들의 노력으로 C 위원회를 참여시키기 위해 n1131[5].제안된 메모리 모델 C++ n2429의 최종 개정안은 코나에서 열린 2007년 10월 회의에서 C++ 초안 표준안으로 받아들여졌다.[6][7]그 후 메모리 모델은 다음 C++ 및 C 표준인 C++11과 C11에 포함되었다.[8][9]
참고 항목
참조
- ^ Jeremy Manson and Brian Goetz (February 2004). "JSR 133 (Java Memory Model) FAQ". Retrieved 2010-10-18.
The Java Memory Model describes what behaviors are legal in multithreaded code, and how threads may interact through memory. It describes the relationship between variables in a program and the low-level details of storing and retrieving them to and from memory or registers in a real computer system. It does this in a way that can be implemented correctly using a wide variety of hardware and a wide variety of compiler optimizations.
- ^ Goetz, Brian (2004-02-24). "Fixing the Java Memory Model, Part 1". Retrieved 2008-02-17.
- ^ Buhr, Peter A. (September 11, 1995). "Are Safe Concurrency Libraries Possible?" (PDF). Retrieved 2015-05-12.
{{cite journal}}
:Cite 저널은 필요로 한다.journal=
(도움말) - ^ Boehm, Hans-J. (November 12, 2004). "Threads Cannot be Implemented as a Library" (PDF). Retrieved 2015-05-12.
- ^ Boehm, Hans; Lea, Doug; Pugh, Bill (2005-08-26). "Implications of C++ Memory Model Discussions on the C Language" (PDF). www.open-std.org. Retrieved 2015-05-12.
- ^ "WG21/N2429: Concurrency memory model (final revision)". www.open-std.org. 2007-10-05. Retrieved 2015-05-12.
- ^ "N2480: A Less Formal Explanation of the Proposed C++ Concurrency Memory Model". www.open-std.org. Retrieved 2015-05-12.
- ^ Alexandrescu, Andrei; Boehm, Hans; Henney, Kevlin; Hutchings, Ben; Lea, Doug; Pugh, Bill (2005-03-04). "Memory Model for Multithreaded C++: Issues" (PDF). Retrieved 2014-04-24.
C++ threading libraries are in the awkward situation of specifying (implicitly or explicitly) an extended memory model for C++ in order to specify program execution.We propose integrating a memory model suitable for multithreaded execution into the C++ Standard.
- ^ Boehm, Hans. "Threads and memory model for C++". Retrieved 2014-04-24.
This [link farm] provides information related to the effort to clarify the meaning of multi-threaded C++ programs, and to provide some standard thread-related APIs where those are currently missing.