<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://wiki-de.moshellshocker.dns64.de/index.php?action=history&amp;feed=atom&amp;title=Volatile_%28Informatik%29</id>
	<title>Volatile (Informatik) - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki-de.moshellshocker.dns64.de/index.php?action=history&amp;feed=atom&amp;title=Volatile_%28Informatik%29"/>
	<link rel="alternate" type="text/html" href="https://wiki-de.moshellshocker.dns64.de/index.php?title=Volatile_(Informatik)&amp;action=history"/>
	<updated>2026-06-06T14:59:40Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Wikipedia (Deutsch) – Lokale Kopie</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wiki-de.moshellshocker.dns64.de/index.php?title=Volatile_(Informatik)&amp;diff=1756533&amp;oldid=prev</id>
		<title>imported&gt;Mielas: Leerzeichen vor Komma entfernt</title>
		<link rel="alternate" type="text/html" href="https://wiki-de.moshellshocker.dns64.de/index.php?title=Volatile_(Informatik)&amp;diff=1756533&amp;oldid=prev"/>
		<updated>2024-07-05T06:56:43Z</updated>

		<summary type="html">&lt;p&gt;Leerzeichen vor Komma entfernt&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{SEITENTITEL:volatile (Informatik)}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Volatile&amp;#039;&amp;#039;&amp;#039; ({{deS|flüchtig, wechselhaft}}) ist ein Zusatz bei der Deklaration von [[Variable (Programmierung)|Variablen]] in Programmiersprachen wie [[C (Programmiersprache)|C]], [[C++]], [[Java (Programmiersprache)|Java]] oder [[C-Sharp|C#]].&lt;br /&gt;
&lt;br /&gt;
In C und C++ spezifiziert dieser Qualifizierer, dass sich der Wert der Variable jederzeit ohne expliziten Zugriff im Quelltext ändern kann, etwa durch externe Hardware oder asynchron ausgeführte [[Interrupt|ISRs]], und dass alle Zugriffe beobachtbares Verhalten darstellen, also auch Lesezugriffe, deren Wert nicht verwendet wird, sowie wiederholtes Schreiben auf dieselbe Adresse, ohne dass explizit gelesen wird. Das schränkt [[Compiler]] bei der Optimierung des Codes ein. Allerdings bezieht sich der Term „beobachtbares Verhalten“ auf das der [[Abstrakte Maschine|abstrakten Maschine]] der Sprachspezifikation,&amp;lt;ref&amp;gt;British Standards Institute (Hrsg.): &amp;#039;&amp;#039;The C Standard. Incorporating Technical Corrigendum 1. (Includes the C Rationale. ISO/IEC 9899:1999).&amp;#039;&amp;#039; John Wiley &amp;amp; Sons, Chichester 2003, ISBN 0-470-84573-2, Kapitel 6.7.3.&amp;lt;/ref&amp;gt; und diese kennt kein [[Thread (Informatik)|Threading]].&amp;lt;ref&amp;gt;{{Internetquelle |url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2016.html |titel=Should &amp;lt;span style=&amp;quot;font-family:monospace, monospace;&amp;quot;&amp;gt;volatile&amp;lt;/span&amp;gt; Acquire Atomicity and Thread Visibility Semantics? |werk=C++ standards committee |datum=2006-04-21 |abruf=2018-03-13}}&amp;lt;/ref&amp;gt; Die Kennzeichnung von Variablen als &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; garantiert also keine Thread-Sicherheit.&amp;lt;ref&amp;gt;Scott Meyers, Andrei Alexandrescu: &amp;#039;&amp;#039;C++ and the Perils of Double-Checked Locking.&amp;#039;&amp;#039; Dr. Dobbs Journal, 2004 ([https://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf pdf]).&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Im Gegensatz dazu werden bei Java und C# Variablen mit &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; gekennzeichnet, auf die verschiedene Threads zugreifen, um die Sichtbarkeit zu synchronisieren.&amp;lt;ref&amp;gt;{{Internetquelle |url=http://msdn.microsoft.com/en-us/library/x13ttww7.aspx |titel=volatile (C# Reference) |hrsg=Microsoft |sprache=en |abruf=2018-03-13}}&amp;lt;/ref&amp;gt; Mit &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; gekennzeichnete Variablen werden in Java nicht zwischengespeichert (z.&amp;amp;nbsp;B. in [[Register (Computer)|Registern]]). Dadurch wird sichergestellt, dass auch bei Zugriff von mehreren Threads der richtige Wert gelesen wird. Der Zusatz &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; sorgt in Java nicht für gegenseitigen Ausschluss und ersetzt somit nicht Synchronisationsmechanismen (z.&amp;amp;nbsp;B. [[Lock|Locks]] oder [[Semaphor (Informatik)|Semaphore]]).&amp;lt;ref&amp;gt;Christian Ullenboom: &amp;#039;&amp;#039;Java ist auch eine Insel. Das umfassende Handbuch. (Aktuell zu Java 7).&amp;#039;&amp;#039; 10., aktualisierte Auflage. Galileo Press, Bonn 2011, ISBN 978-3-8362-1802-3, Kapitel 9.7.1. ([http://openbook.galileodesign.de/javainsel5/javainsel09_006.htm#Rxx747java09006040002E61F04E100 openbook.galileodesign.de]){{Abrufdatum|2012-01-30}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Beispiele in C ==&lt;br /&gt;
Ohne &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; könnte der Compiler die Schleife im folgenden Programmausschnitt durch eine einfache Endlosschleife ersetzen und die Variable &amp;lt;code&amp;gt;status&amp;lt;/code&amp;gt; wegoptimieren:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
static volatile int status;&lt;br /&gt;
&lt;br /&gt;
void poll_status(void)&lt;br /&gt;
{&lt;br /&gt;
    status = 0;&lt;br /&gt;
&lt;br /&gt;
    while (status == 0) {&lt;br /&gt;
        /* do nothing */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In folgendem Beispiel könnte ohne &amp;lt;code&amp;gt;volatile&amp;lt;/code&amp;gt; ein optimierender Compiler die bedingte Anweisung mit der Grußformel eliminieren.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;setjmp.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
jmp_buf env;&lt;br /&gt;
&lt;br /&gt;
int main ()&lt;br /&gt;
{&lt;br /&gt;
   volatile int status = 0;&lt;br /&gt;
&lt;br /&gt;
   if (setjmp (env)) {&lt;br /&gt;
      if (status == 1) {&lt;br /&gt;
         puts (&amp;quot;Hello World&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      return 0;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   status = 1;&lt;br /&gt;
   longjmp (env, 1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Einzelnachweise ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Kategorie:Programmiersprachelement]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Mielas</name></author>
	</entry>
</feed>