<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Memory_model_%28programming%29</id>
	<title>Memory model (programming) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Memory_model_%28programming%29"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Memory_model_(programming)&amp;action=history"/>
	<updated>2026-05-10T03:54:00Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Memory_model_(programming)&amp;diff=7004085&amp;oldid=prev</id>
		<title>imported&gt;Rublov: /* History and significance */ MOS</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Memory_model_(programming)&amp;diff=7004085&amp;oldid=prev"/>
		<updated>2024-08-25T15:51:25Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;History and significance: &lt;/span&gt; MOS&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Short description|Interactions of threads through memory}}&lt;br /&gt;
{{about|a concept in multi-thread programming|details of memory addressing|Memory address#Memory models}}&lt;br /&gt;
&lt;br /&gt;
In computing, a &amp;#039;&amp;#039;&amp;#039;memory model&amp;#039;&amp;#039;&amp;#039; describes the interactions of [[Thread (computer science)|threads]] through [[memory (computing)|memory]] and their shared use of the [[data (computing)|data]].&lt;br /&gt;
&lt;br /&gt;
==History and significance==&lt;br /&gt;
A memory model allows a compiler to perform many important optimizations. [[Compiler optimization]]s like [[loop fusion]] move statements in the program, which can influence the order of read and write operations of potentially shared [[variable (programming)|variables]]. Changes in the ordering of reads and writes can cause [[race condition]]s. Without a memory model, a compiler may not apply such optimizations to multi-threaded programs at all, or it may apply optimizations that are incompatible with multi-threading, leading to bugs.&lt;br /&gt;
&lt;br /&gt;
Modern programming languages like [[Java (programming language)|Java]] therefore implement a memory model. The memory model specifies [[synchronization barrier]]s that are established via special, well-defined synchronization operations such as acquiring a lock by entering a synchronized block or method. The memory model stipulates that changes to the values of shared variables only need to be made visible to other threads when such a synchronization barrier is reached. Moreover, the entire notion of a [[race condition]] is  defined over the order of operations with respect to these memory barriers.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| url=http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html&lt;br /&gt;
| title=JSR 133 (Java Memory Model) FAQ&lt;br /&gt;
| author=[[Jeremy Manson]] and [[Brian Goetz]]&lt;br /&gt;
| quote=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.&lt;br /&gt;
| date=February 2004&lt;br /&gt;
| access-date=2010-10-18}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These semantics then give optimizing compilers a higher degree of freedom when applying optimizations: the compiler needs to make sure {{em|only}} that the values of (potentially shared) variables at synchronization barriers are guaranteed to be the same in both the optimized and unoptimized code. In particular, reordering statements in a block of code that contains no synchronization barrier is assumed to be safe by the compiler.&lt;br /&gt;
&lt;br /&gt;
Most research in the area of memory models revolves around:&lt;br /&gt;
&lt;br /&gt;
* Designing a memory model that allows a maximal degree of freedom for compiler optimizations while still giving sufficient guarantees about race-free and (perhaps more importantly) race-containing programs.&lt;br /&gt;
* Proving [[program optimization]]s that are correct with respect to such a memory model.&lt;br /&gt;
&lt;br /&gt;
The [[Java memory model]] was the first attempt to provide a comprehensive threading memory model for a popular programming language.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| url=http://www.ibm.com/developerworks/library/j-jtp02244.html&lt;br /&gt;
| title=Fixing the Java Memory Model, Part 1&lt;br /&gt;
| date=2004-02-24&lt;br /&gt;
| last=Goetz|first=Brian&lt;br /&gt;
| website=[[IBM]]&lt;br /&gt;
| access-date=2008-02-17}}&amp;lt;/ref&amp;gt; After it was established that threads could not be implemented safely as a [[Library (computing)|library]] without placing certain restrictions on the implementation and, in particular, that the [[C (programming language)|C]] and [[C++]] standards ([[C99]] and [[C++03]]) lacked necessary restrictions,&amp;lt;ref&amp;gt;{{Cite journal|url = http://plg.uwaterloo.ca/usystem/pub/uSystem/LibraryApproach.pdf&lt;br /&gt;
|title = Are Safe Concurrency Libraries Possible?&lt;br /&gt;
|journal = Communications of the ACM&lt;br /&gt;
|last = Buhr&lt;br /&gt;
|first = Peter A.&lt;br /&gt;
|date = September 11, 1995&lt;br /&gt;
|access-date = 2015-05-12}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web|title = Threads Cannot be Implemented as a Library|url = http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf|access-date = 2015-05-12|last = Boehm|first = Hans-J.|date = November 12, 2004|archive-date = 2017-05-30|archive-url = https://web.archive.org/web/20170530160703/http://www.hpl.hp.com/techreports/2004/HPL-2004-209.pdf|url-status = dead}}&amp;lt;/ref&amp;gt; the C++ threading subcommittee set to work on suitable memory model; in 2005, they submitted C working document n1131&amp;lt;ref&amp;gt;{{Cite web|title = Implications of C++ Memory Model Discussions on the C Language|url = http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1131.pdf|website = www.open-std.org|access-date = 2015-05-12|date = 2005-08-26|last1 = Boehm|first1 = Hans|author-link = Hans-J. Boehm|last2 = Lea|first2 = Doug|author-link2 = Doug Lea|last3 = Pugh|first3 = Bill}}&amp;lt;/ref&amp;gt; to get the C Committee on board with their efforts. The final revision of the proposed memory model, C++ n2429,&amp;lt;ref&amp;gt;{{Cite web|title = WG21/N2429: Concurrency memory model (final revision)|url = http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2429.htm|website = www.open-std.org|access-date = 2015-05-12|date = 2007-10-05}}&amp;lt;/ref&amp;gt; was accepted into the C++ draft standard at the October 2007 meeting in Kona.&amp;lt;ref&amp;gt;{{Cite web|title = N2480: A Less Formal Explanation of the Proposed C++ Concurrency Memory Model|url = http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2480.html|website = www.open-std.org|access-date = 2015-05-12}}&amp;lt;/ref&amp;gt; The memory model was then included in the next C++ and C standards, [[C++11]] and [[C11 (C standard revision)|C11]].&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1777.pdf&lt;br /&gt;
| title=Memory Model for Multithreaded C++: Issues&lt;br /&gt;
| date=2005-03-04&lt;br /&gt;
| last1=Alexandrescu|first1=Andrei&lt;br /&gt;
| last2=Boehm|first2=Hans&lt;br /&gt;
| last3=Henney|first3=Kevlin&lt;br /&gt;
| last4=Hutchings|first4=Ben&lt;br /&gt;
| last5=Lea|first5=Doug&lt;br /&gt;
| last6=Pugh|first6=Bill&lt;br /&gt;
| quote=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.&lt;br /&gt;
| access-date=2014-04-24}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| url=http://www.hboehm.info/c++mm/&lt;br /&gt;
| title=Threads and memory model for C++&lt;br /&gt;
| last=Boehm|first=Hans&lt;br /&gt;
| access-date=2014-04-24&lt;br /&gt;
| quote=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.}}&amp;lt;/ref&amp;gt; The [[Rust (programming language)|Rust programming language]] inherited most of C/C++&amp;#039;s memory model.&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
| url=https://doc.rust-lang.org/nomicon/atomics.html&lt;br /&gt;
| title=The Rustonomicon, Atomics&lt;br /&gt;
| quote=Rust pretty blatantly just inherits the memory model for atomics from C++20.&lt;br /&gt;
| access-date=2024-07-08}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Memory ordering]]&lt;br /&gt;
*[[Memory barrier]]&lt;br /&gt;
*[[Consistency model]]&lt;br /&gt;
*[[Shared memory (interprocess communication)]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist|2}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Computer memory]]&lt;br /&gt;
[[Category:Consistency models]]&lt;br /&gt;
[[Category:Compiler construction]]&lt;br /&gt;
[[Category:Programming language design]]&lt;br /&gt;
[[Category:Run-time systems]]&lt;br /&gt;
[[Category:Concurrency (computer science)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{compu-prog-stub}}&lt;/div&gt;</summary>
		<author><name>imported&gt;Rublov</name></author>
	</entry>
</feed>