Share to: share facebook share twitter share wa share telegram print page

Shared memory

An illustration of a shared memory system of three processors

In computer science, shared memory is memory that may be simultaneously accessed by multiple programs with an intent to provide communication among them or avoid redundant copies. Shared memory is an efficient means of passing data between programs. Depending on context, programs may run on a single processor or on multiple separate processors.

Using memory for communication inside a single program, e.g. among its multiple threads, is also referred to as shared memory.

In hardware

HSA defines a special case of memory sharing, where the MMU of the CPU and the IOMMU of the GPU have an identical pageable virtual address space.

In computer hardware, shared memory refers to a (typically large) block of random access memory (RAM) that can be accessed by several different central processing units (CPUs) in a multiprocessor computer system.

Shared memory systems may use:[1]

A shared memory system is relatively easy to program since all processors share a single view of data and the communication between processors can be as fast as memory accesses to the same location. The issue with shared memory systems is that many CPUs need fast access to memory and will likely cache memory, which has two complications:

  • access time degradation: when several processors try to access the same memory location it causes contention. Trying to access nearby memory locations may cause false sharing. Shared memory computers cannot scale very well. Most of them have ten or fewer processors;
  • lack of data coherence: whenever one cache is updated with information that may be used by other processors, the change needs to be reflected to the other processors, otherwise the different processors will be working with incoherent data. Such cache coherence protocols can, when they work well, provide extremely high-performance access to shared information between multiple processors. On the other hand, they can sometimes become overloaded and become a bottleneck to performance.

Technologies like crossbar switches, Omega networks, HyperTransport or front-side bus can be used to dampen the bottleneck-effects.

In case of a Heterogeneous System Architecture (processor architecture that integrates different types of processors, such as CPUs and GPUs, with shared memory), the memory management unit (MMU) of the CPU and the input–output memory management unit (IOMMU) of the GPU have to share certain characteristics, like a common address space.

The alternatives to shared memory are distributed memory and distributed shared memory, each having a similar set of issues.

In software

In computer software, shared memory is either

  • a method of inter-process communication (IPC), i.e. a way of exchanging data between programs running at the same time. One process will create an area in RAM which other processes can access;
  • a method of conserving memory space by directing accesses to what would ordinarily be copies of a piece of data to a single instance instead, by using virtual memory mappings or with explicit support of the program in question. This is most often used for shared libraries and for Execute in place (XIP).

Since both processes can access the shared memory area like regular working memory, this is a very fast way of communication (as opposed to other mechanisms of IPC such as named pipes, Unix domain sockets or CORBA). On the other hand, it is less scalable, as for example the communicating processes must be running on the same machine (of other IPC methods, only Internet domain sockets—not Unix domain sockets—can use a computer network), and care must be taken to avoid issues if processes sharing memory are running on separate CPUs and the underlying architecture is not cache coherent.

IPC by shared memory is used for example to transfer images between the application and the X server on Unix systems, or inside the IStream object returned by CoMarshalInterThreadInterfaceInStream in the COM libraries under Windows.

Dynamic libraries are generally held in memory once and mapped to multiple processes, and only pages that had to be customized for the individual process (because a symbol resolved differently there) are duplicated, usually with a mechanism known as copy-on-write that transparently copies the page when a write is attempted, and then lets the write succeed on the private copy.

Compared to multiple address space operating systems, memory sharing -- especially of sharing procedures or pointer-based structures -- is simpler in single address space operating systems.[2]

Support on Unix-like systems

POSIX provides a standardized API for using shared memory, POSIX Shared Memory. This uses the function shm_open from sys/mman.h.[3] POSIX interprocess communication (part of the POSIX:XSI Extension) includes the shared-memory functions shmat, shmctl, shmdt and shmget.[4][5] Unix System V provides an API for shared memory as well. This uses shmget from sys/shm.h. BSD systems provide "anonymous mapped memory" which can be used by several processes.

The shared memory created by shm_open is persistent. It stays in the system until explicitly removed by a process. This has a drawback in that if the process crashes and fails to clean up shared memory it will stay until system shutdown; that limitation is not present in an Android-specific implementation dubbed ashmem.[6]

POSIX also provides the mmap API for mapping files into memory; a mapping can be shared, allowing the file's contents to be used as shared memory.

Linux distributions based on the 2.6 kernel and later offer /dev/shm as shared memory in the form of a RAM disk, more specifically as a world-writable directory (a directory in which every user of the system can create files) that is stored in memory. Both the RedHat and Debian based distributions include it by default. Support for this type of RAM disk is completely optional within the kernel configuration file.[7]

Support on Windows

On Windows, one can use CreateFileMapping and MapViewOfFile functions to map a region of a file into memory in multiple processes.[8]

Cross-platform support

Some C++ libraries provide a portable and object-oriented access to shared memory functionality. For example, Boost contains the Boost.Interprocess C++ Library[9] and Qt provides the QSharedMemory class.[10]

Programming language support

For programming languages with POSIX bindings (say, C/C++), shared memory regions can be created and accessed by calling the functions provided by the operating system. Other programming languages may have their own ways of using these operating facilities for similar effect. For example, PHP provides an API to create shared memory, similar to POSIX functions.[11]

See also

References

  1. ^ El-Rewini, Hesham; Abd-El-Barr, Mostafa (2005). Advanced Computer Architecture and Parallel Processing. Wiley-Interscience. pp. 77–80. ISBN 978-0-471-46740-3.
  2. ^ Jeffrey S. Chase; Henry M. Levy; Michael J. Feeley; and Edward D. Lazowska. "Sharing and Protection in a Single Address Space Operating System". doi:10.1145/195792.195795 1993. p. 3
  3. ^ Documentation of shm_open from the Single Unix Specification
  4. ^ Robbins, Kay A.; Robbins, Steven (2003). Unix systems programming: communication, concurrency, and threads (2 ed.). Prentice Hall PTR. p. 512. ISBN 978-0-13-042411-2. Retrieved 2011-05-13. The POSIX interprocess communication (IPC) is part of the POSIX:XSI Extension and has its origin in Unix System V interprocess communication.
  5. ^ Shared memory facility from the Single Unix Specification.
  6. ^ "Android Kernel Features". elinux.org. Retrieved 12 Dec 2022.
  7. ^ Christoph Rohland; Hugh Dickins; KOSAKI Motohiro. "tmpfs.txt". kernel.org. Retrieved 2010-03-16.
  8. ^ Creating Named Shared Memory from MSDN.
  9. ^ Boost.Interprocess C++ Library
  10. ^ "QSharedMemory Class Reference".
  11. ^ Shared Memory Functions in PHP-API

Read other articles:

Milan LuthriaMilan LuthriaLahirIndiaPekerjaanSutradaraTahun aktif1999 – sekarangDikenal atasMenyutradarai film Once Upon a Time in Mumbai (2010),The Dirty Picture (2011)Orang tuaRaj Khosla (bapak) Milan Luthria adalah seorang sutradara India yang berkarya dalam film-film Hindi. Ia paling dikenal sebagai sutradara Once Upon a Time in Mumbai (2010) yang dibintangi oleh Ajay Devgan. Ia adalah keponakan dari produser dan sutradara Mahesh Bhatt.[1] Kehidupan pribadi Ia adalah putra dar…

AkadSingel oleh Payung Teduhdari album Ruang TungguDirilis23 Juni 2017FormatUnduhan digitalGenreJazz, PopDurasi4:19LabelPararaPenciptaMoh. Istiqamah DjamadProduserAroel Stereomantic & Payung Teduh Akad adalah lagu dari grup musik Indonesia, Payung Teduh, yang ditulis oleh vokalis mereka Moh. Istiqamah Djamad. Lagu ini dirilis sebagai singel pertama dari album ketiga mereka, Ruang Tunggu, pada tanggal 23 Juni 2017. Akad memenangkan Anugerah Musik Indonesia 2017 untuk kategori Karya Produksi A…

Dato Rusman Sutan Nurdin Wakil Gubernur AALMasa jabatan14 Februari 2023 – 26 Juni 2023 PendahuluEdy PrakosoPenggantiArif BadrudinDirdok KodiklatalMasa jabatan25 Oktober 2021 – 21 Januari 2022 PendahuluAntongan SimatupangPenggantiKemas M. Ikhwan Madani Informasi pribadiLahir24 Juni 1970 (umur 53)Bajawa, Nusa Tenggara TimurAlma materAkademi Angkatan Laut (1994)Penghargaan sipilAdhi Makayasa (1994)Karier militerPihak IndonesiaDinas/cabang TNI Angkatan LautMasa d…

Gerbang Utama Puri Agung Denpasar sebelum Perang Puputan Badung. Puri Agung Denpasar (Puri Agung Satria) merupakan sebuah puri peninggalan raja-raja bali khususnya di daerah Bali selatan.[1] Puri ini didirikan oleh Kyai Agung Made Ngurah (I Gusti Ngurah Made Pemecutan) sebagai Raja Denpasar pertama dan pembangunannya selesai pada tahun 1788 setelah sebelumnya beliau memindahkan pusat pemerintahan Kerajaan Badung dari Puri Jambe Kesatria. Selanjutnya pusat pemerintahan Kerajaan Badung ber…

У этого термина существуют и другие значения, см. Терновый венец (значения). Терновый венец в соборе Нотр-Дам де Пари Терно́вый вене́ц (др.-греч. στέφανος ἐξ ἀκανθῶν) — венец из ветвей растения с шипами (терниями), который, согласно Евангелиям, был возложен на голову Иисус…

The Rajah's Diamond The Rajah's Diamond on New Arabian NightsAuthorRobert Louis StevensonCountryScotlandLanguageEnglishSeriesLater-day Arabian NightsGenreDetective fiction short storyPublisherLondon MagazinePublication dateJune–October 1878Media typePrint (Periodical)Preceded byThe Suicide Club  The Rajah's Diamond is a cycle of four short stories by Robert Louis Stevenson. First published in 1878 in a serial periodical London Magazine, they were republished in the first volume …

US television show For other uses, see 48 Hours. 48 HoursGenreDocumentaryNewsmagazineCreated byHoward StringerDirected byRob KlugPresented by Erin Moriarty Peter Van Sant Natalie Morales Jim Axelrod Jericka Duncan Michelle Miller David Begnaud Jericka Duncan Jonathan Vigliotti ComposerJulian HarrisCountry of originUnited StatesOriginal languageEnglishNo. of seasons36No. of episodes991[1]ProductionExecutive producerJudy TygardProducersChuck Stevenson, Liza Findley, Paul La Rosa, Ruth Chen…

Chronologie de la France ◄◄ 1780 1781 1782 1783 1784 1785 1786 1787 1788 ►► Chronologies Le Serment des Horaces de Jacques Louis David.Données clés 1781 1782 1783  1784  1785 1786 1787Décennies :1750 1760 1770  1780  1790 1800 1810Siècles :XVIe XVIIe  XVIIIe  XIXe XXeMillénaires :-Ier Ier  IIe  IIIe Chronologies géographiques Afrique Afrique du Sud, Algérie, Angola, Bénin, Botswana, Burkina Faso, Burundi, Cameroun, Cap-Vert, …

Species of bat Robust yellow bat Conservation status Least Concern  (IUCN 3.1)[1] Scientific classification Domain: Eukaryota Kingdom: Animalia Phylum: Chordata Class: Mammalia Order: Chiroptera Family: Vespertilionidae Genus: Scotophilus Species: S. robustus Binomial name Scotophilus robustusMilne-Edwards, 1881 Robust yellow bat range The robust yellow bat (Scotophilus robustus) is a species of vesper bat. It is found only in Madagascar. References ^ Monadjem, A.; Razafimanaha…

Vie nuoveStato Italia Linguaitaliano Periodicitàsettimanale FondatoreLuigi Longo Fondazione1946 Chiusura1978 SedeRoma   Modifica dati su Wikidata · Manuale Vie nuove è stata una rivista legata al Partito Comunista Italiano fondata nel 1946 da Luigi Longo. Indice 1 Storia 2 Note 3 Voci correlate 4 Collegamenti esterni Storia Inizialmente sottotitolata Settimanale di orientamento e lotta politica, la rivista «fu costretta fin quasi da subito a dare ampio spazio ad argomenti legg…

This article is about a soundtrack. For the video game, see Commandos 3: Destination Berlin. This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Destination Berlin – news · newspapers · books · scholar · JSTOR (August 2016) (Learn how and when to remove this template message) 1989 soundtrack album by Tangerine …

English cognitive psychologist (1935–2018) Anne M. TreismanTreisman in 2011, Princeton University, recipient of the National Medal of ScienceBornAnne Marie Taylor(1935-02-27)27 February 1935Wakefield, West Riding of Yorkshire, EnglandDied9 February 2018(2018-02-09) (aged 82)New York City, USAlma materNewnham College, CambridgeSomerville College, OxfordKnown forFeature integration theory, Attenuation theorySpouses Michel Treisman ​ ​(m. 1960; div.…

For other uses, see Vimy (disambiguation). Commune in Hauts-de-France, FranceVimyCommuneVimy city hall Coat of armsLocation of Vimy VimyShow map of FranceVimyShow map of Hauts-de-FranceCoordinates: 50°22′24″N 2°48′41″E / 50.3733°N 2.8114°E / 50.3733; 2.8114CountryFranceRegionHauts-de-FranceDepartmentPas-de-CalaisArrondissementLensCantonLiévinIntercommunalityCA Lens-LiévinGovernment • Mayor (2021–2026) Christian Sprimont[1]Area111.33…

Kontes Lagu Eurovision 1969 Final 29 Maret 1969 Pembawa Acara Laurita Valenzuela Konduktor Augusto Algueró Direktur Ramón Díez Penyiar Tuan Rumah TVE Tempat Teatro RealMadrid, Spanyol Lagu pemenang  SpanyolVivo cantando Britania RayaBoom Bang-a-Bang BelandaDe troubadour PrancisUn jour, un enfant Sistem pemberian suara Setiap negara memiliki 10 juri yang memberikan 1 poin terhadap setiap peserta favorit mereka masing-masing. Jumlah kontestan 16 Partisipasi pertama Tidak ada…

Remaja di Lampu MerahSutradaraSyamsul FuadProduserTaharDitulis olehSyamsul FuadPemeranRano KarnoIta MustafaVita FatimahYati OctaviaDoddy SukmaJunaedi SalatEl ManikSugata LSherly MalintonPenata musikRachman APenyuntingMuryadiDistributorPT. Japos FilmTanggal rilis1979DurasimenitNegaraIndonesia Remaja di Lampu Merah adalah film Indonesia tahun 1979 dengan disutradarai oleh Syamsul Fuad dan dibintangi oleh Rano Karno dan Ita Mustafa. Sinopsis Andy(Rano Karno), pelajar SMA, menderita frustasi. …

American legislative district West Virginia's 16thState Senate district From 2012 to 2022 From 2022 onwardSenator  Jason Barrett R–Martinsburg Patricia Rucker R–Harpers Ferry Demographics82% White8% Black5% Hispanic1% Asian3% OtherPopulation (2017)109,798[1] West Virginia's 16th Senate district is one of 17 districts in the West Virginia Senate. It is currently represented by Democrat Hannah Geffert and Republican Patricia Rucker.[2][3&#…

Charles-François Lebrun III console della Prima Repubblica FranceseDurata mandato1º gennaio 1800 –18 maggio 1804 PredecessoreRoger Ducos Successoreabolizione della carica Arci-Tesoriere del Primo Impero FranceseDurata mandato18 maggio 1804 –2 aprile 1814 Predecessoreistituzione della carica Successoreabolizione della carica Deputato all'Assemblea Nazionale CostituenteDurata mandato25 marzo 1789 –16 maggio 1791 Dati generaliPartito politicoIn…

GSh-18 (ГШ-18) Pistol GSh-18 Gryazev dan Shipunov 9mm Jenis Pistol semi-otomatis Negara asal Rusia Sejarah pemakaian Masa penggunaan 2000–sekarang Digunakan oleh Rusia Sejarah produksi Perancang V.P. Gryazev[1]A.G. Shipunov[1] Tahun 1998–2000[2] Produsen KBP Instrument Design Bureau Biaya produksi 14.810 Rubel (2008)23.314,44 Rubel(2012)[3] Diproduksi 2001[1]–sekarang Varian berbagai versi sipil Spesifikasi Berat 590 g (21&…

Частина серії проФілософіяLeft to right: Plato, Kant, Nietzsche, Buddha, Confucius, AverroesПлатонКантНіцшеБуддаКонфуційАверроес Філософи Епістемологи Естетики Етики Логіки Метафізики Соціально-політичні філософи Традиції Аналітична Арістотелівська Африканська Близькосхідна іранська Буддійсь…

County in Arkansas, United States Not to be confused with Lincoln, Arkansas. County in ArkansasLincoln CountyCountyLincoln County Courthouse in Star CityLocation within the U.S. state of ArkansasArkansas's location within the U.S.Coordinates: 33°57′35″N 91°43′07″W / 33.959722222222°N 91.718611111111°W / 33.959722222222; -91.718611111111Country United StatesState ArkansasFoundedMarch 28, 1871Named forAbraham Lincoln[1]SeatStar CityLargest city…

Kembali kehalaman sebelumnya