Fetch-and-add

Fetch-and-add

Fetch-and-add ist ein Fachbegriff der Informatik, welcher ein Verfahren zur atomaren Veränderung eines Speicherbereichs beschreibt.

Inhaltsverzeichnis

Arbeitsweise

Das Verfahren wird mithilfe eines Funktionsaufrufs, der vom Betriebssystem verarbeitet wird, implementiert. Der Inhalt einer Speicherzelle wird ausgelesen und im selben Speicherzyklus durch einen neuen Wert überschrieben, der um 1 größer ist. Der Vorteil ist, dass andere Prozesse den Wert der Variable während dieses Vorgangs nicht verändern können. Inkonsistenzen und Datenverluste sind somit ausgeschlossen. Für die Verwendung von Fetch-and-add muss eine entsprechende Hardware-Unterstützung vorhanden sein.

Implementierung

Beispielhaft soll eine mögliche Umsetzung der Technik in der Programmiersprache C angegeben werden. Je nach verwendeter Programmiersprache kann sich der Aufruf unterscheiden.

<<atomic>> int FetchAndAdd(address alterWert) {
    int wert = *alterWert;
    *alterWert = wert + 1;
    return wert;
}

Für diese Implementierung wird ein Zeiger auf die Speicherzelle, die verändert werden soll, verwendet (hier alterWert)

Abgrenzung zu anderen Verfahren

Neben Fetch-and-Add gibt es noch weitere Möglichkeiten, exklusiven Zugriff auf Speicherbereiche zu gewähren. So reicht es bei Einprozessorsystemen, die Ausführung von Interrupts zu verhindern, während der Speicherinhalt durch einen Prozess verändert wird. Auf Systemen mit mehreren Prozessoren (Multicore-Architekturen) reicht dieses Vorgehen jedoch nicht aus.

Eine weitere Alternative zu Fetch-and-add ist Compare-and-swap.

Literatur


Wikimedia Foundation.

Игры ⚽ Поможем написать реферат

Schlagen Sie auch in anderen Wörterbüchern nach:

  • Fetch-and-add — In computer science, the fetch and add CPU instruction is a special instruction that atomically modifies the contents of a memory location. It is used to implement Mutual exclusion and concurrent algorithms in multiprocessor systems.In… …   Wikipedia

  • Compare-and-swap — In computer science, the compare and swap (CAS) CPU instruction is a special instruction that atomically compares the contents of a memory location to a given value and, only if they are the same, modifies the contents of that memory location to… …   Wikipedia

  • Test-and-set — In computer science, the test and set instruction is an instruction used to both test and (conditionally) write to a memory location as part of a single atomic (i.e. non interruptible) operation. This means setting a value, but first performing… …   Wikipedia

  • Compare-and-swap — (CAS) (engl. für „Vergleichen und Tauschen“) Instruktionen werden in der Informatik verwendet, um Locking und Synchronisationsoperationen zu implementieren. Eine Speicherstelle wird mit einem vorgegebenen Wert verglichen, und bei Übereinstimmung… …   Deutsch Wikipedia

  • Tiree and Coll —    TIREE and COLL, a parish, in the division of Mull, county of Argyll, the one district 30 miles (W.) and the other 20 (W. by N.) from Tobermory; containing 5833 inhabitants, of whom 1442 are in the island of Coll. Tiree is supposed to have… …   A Topographical dictionary of Scotland

  • Esben and the Witch — Infobox Folk tale Folk Tale Name = Esben and the Witch Image Caption = AKA = Aarne Thompson Grouping = 327B (The Small Boy defeats Ogre) Mythology = Country = Denmark Region = Origin Date = Published In = The Pink Fairy Book A Book of Witches… …   Wikipedia

  • Daisy Fay and the Miracle Man —   paper …   Wikipedia

  • List of Looney Tunes and Merrie Melodies characters — This is an incomplete list of Looney Tunes and Merrie Melodies characters. Contents 0–9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z B …   Wikipedia

  • Ultracomputer — The NYU Ultracomputer is a significant processor design in the history of parallel computing. The system has N processors, N memories and an N log N message passing switch connecting them. The switch uses an innovative Fetch and Add instruction… …   Wikipedia

  • Ultracomputer — Ultracomputer  проект суперкомпьютера, созданный в Нью Йоркском университете. Система могла иметь N процессоров, N модулей памяти и N log N коммутаторов передачи сообщений между ними. В коммутаторах использовалась инновационная на то время… …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”