Message passing

In computer science, message passing is a technique for invoking behavior (i.e., running a program) on a computer. The invoking program sends a message to a process (which may be an actor or object) and relies on that process and its supporting infrastructure to then select and run some appropriate code. Message passing differs from conventional programming where a process, subroutine, or function is directly invoked by name. Message passing is key to some models of concurrency and object-oriented programming.

Message passing is ubiquitous in modern computer software.[citation needed] It is used as a way for the objects that make up a program to work with each other and as a means for objects and systems running on different computers (e.g., the Internet) to interact. Message passing may be implemented by various mechanisms, including channels.

Overview

Message passing is a technique for invoking behavior (i.e., running a program) on a computer. In contrast to the traditional technique of calling a program by name, message passing uses an object model to distinguish the general function from the specific implementations. The invoking program sends a message and relies on the object to select and execute the appropriate code. The justifications for using an intermediate layer essentially falls into two categories: encapsulation and distribution.

Encapsulation is the idea that software objects should be able to invoke services on other objects without knowing or caring about how those services are implemented. Encapsulation can reduce the amount of coding logic and make systems more maintainable. E.g., rather than having IF-THEN statements that determine which subroutine or function to call a developer can just send a message to the object and the object will select the appropriate code based on its type.

One of the first examples of how this can be used was in the domain of computer graphics. There are various complexities involved in manipulating graphic objects. For example, simply using the right formula to compute the area of an enclosed shape will vary depending on if the shape is a triangle, rectangle, ellipse, or circle. In traditional computer programming this would result in long IF-THEN statements testing what sort of object the shape was and calling the appropriate code. The object-oriented way to handle this is to define a class called Shape with subclasses such as Rectangle and Ellipse (which in turn have subclasses Square and Circle) and then to simply send a message to any Shape asking it to compute its area. Each Shape object will then invoke the subclass's method with the formula appropriate for that kind of object.[1]

Distributed message passing provides developers with a layer of the architecture that provides common services to build systems made up of sub-systems that run on disparate computers in different locations and at different times. When a distributed object is sending a message, the messaging layer can take care of issues such as:

  • Finding the process using different operating systems and programming languages, at different locations from where the message originated.
  • Saving the message on a queue if the appropriate object to handle the message is not currently running and then invoking the message when the object is available. Also, storing the result if needed until the sending object is ready to receive it.
  • Controlling various transactional requirements for distributed transactions, e.g. atomicity, consistency, isolation, durability (ACID) testing the data.[2]

Synchronous versus asynchronous message passing

Synchronous message passing

Synchronous message passing occurs between objects that are running at the same time. It is used by object-oriented programming languages such as Java and Smalltalk.

Synchronous messaging is analogous to a synchronous function call; just as the function caller waits until the function completes, the sending process waits until the receiving process completes. This can make synchronous communication unworkable for some applications. For example, large, distributed systems may not perform well enough to be usable. Such large, distributed systems may need to operate while some of their subsystems are down for maintenance, etc.

Imagine a busy business office having 100 desktop computers that send emails to each other using synchronous message passing exclusively. One worker turning off their computer can cause the other 99 computers to freeze until the worker turns their computer back on to process a single email.

Asynchronous message passing

With asynchronous message passing the receiving object can be down or busy when the requesting object sends the message. Continuing the function call analogy, it is like a function call that returns immediately, without waiting for the called function to complete. Messages are sent to a queue where they are stored until the receiving process requests them. The receiving process processes its messages and sends results to a queue for pickup by the original process (or some designated next process).[3]

Asynchronous messaging requires additional capabilities for storing and retransmitting data for systems that may not run concurrently, and are generally handled by an intermediary level of software (often called middleware); a common type being Message-oriented middleware (MOM).

The buffer required in asynchronous communication can cause problems when it is full. A decision has to be made whether to block the sender or whether to discard future messages. A blocked sender may lead to deadlock. If messages are dropped, communication is no longer reliable.

Hybrids

Synchronous communication can be built on top of asynchronous communication by using a Synchronizer. For example, the α-Synchronizer works by ensuring that the sender always waits for an acknowledgement message from the receiver. The sender only sends the next message after the acknowledgement has been received. On the other hand, asynchronous communication can also be built on top of synchronous communication. For example, modern microkernels generally only provide a synchronous messaging primitive[citation needed] and asynchronous messaging can be implemented on top by using helper threads.

Distributed objects

Message-passing systems use either distributed or local objects. With distributed objects the sender and receiver may be on different computers, running different operating systems, using different programming languages, etc. In this case the bus layer takes care of details about converting data from one system to another, sending and receiving data across the network, etc. The Remote Procedure Call (RPC) protocol in Unix was an early example of this. With this type of message passing it is not a requirement that sender nor receiver use object-oriented programming. Procedural language systems can be wrapped and treated as large grained objects capable of sending and receiving messages.[4]

Examples of systems that support distributed objects are: Emerald, ONC RPC, CORBA, Java RMI, DCOM, SOAP, .NET Remoting, CTOS, QNX Neutrino RTOS, OpenBinder and D-Bus. Distributed object systems have been called "shared nothing" systems because the message passing abstraction hides underlying state changes that may be used in the implementation of sending messages.

Distributed, or asynchronous, message-passing has additional overhead compared to calling a procedure. In message-passing, arguments must be copied to the new message. Some arguments can contain megabytes of data, all of which must be copied and transmitted to the receiving object.

Traditional procedure calls differ from message-passing in terms of memory usage, transfer time and locality. Arguments are passed to the receiver typically by general-purpose registers requiring no additional storage nor transfer time, or in a parameter list containing the arguments' addresses (a few bits). Address-passing is not possible for distributed systems since the systems use separate address spaces.

Web browsers and web servers are examples of processes that communicate by message-passing. A URL is an example of referencing a resource without exposing process internals.

A subroutine call or method invocation will not exit until the invoked computation has terminated. Asynchronous message-passing, by contrast, can result in a response arriving a significant time after the request message was sent.

A message-handler will, in general, process [5] messages from more than one sender. This means its state can change for reasons unrelated to the behavior of a single sender or client process. This is in contrast to the typical behavior of an object upon which methods are being invoked: the latter is expected to remain in the same state between method invocations. In other words, the message-handler behaves analogously to a volatile object.

Mathematical models

The prominent mathematical models of message passing are the Actor model and Pi calculus.[6][7] In mathematical terms a message is the single means to pass control to an object. If the object responds to the message, it has a method for that message.

Alan Kay has argued that message passing is more important than objects in OOP, and that objects themselves are often over-emphasized. The live distributed objects programming model builds upon this observation; it uses the concept of a distributed data flow to characterize the behavior of a complex distributed system in terms of message patterns, using high-level, functional-style specifications.[8]

Examples

See also

References

  1. ^ Goldberg, Adele; David Robson (1989). Smalltalk-80 The Language. Addison Wesley. pp. 5–16. ISBN 0-201-13688-0.
  2. ^ Orfali, Robert (1996). The Essential Client/Server Survival Guide. New York: Wiley Computer Publishing. pp. 1–22. ISBN 0-471-15325-7.
  3. ^ Orfali, Robert (1996). The Essential Client/Server Survival Guide. New York: Wiley Computer Publishing. pp. 95–133. ISBN 0-471-15325-7.
  4. ^ Orfali, Robert (1996). The Essential Client/Server Survival Guide. New York: Wiley Computer Publishing. pp. 375–397. ISBN 0-471-15325-7.
  5. ^ "Process of Hide messages". Message. 2022-04-13. Retrieved 2022-04-12.
  6. ^ Milner, Robin (Jan 1993). "Elements of interaction: Turing award lecture". Communications of the ACM. 36 (1): 78–89. doi:10.1145/151233.151240.
  7. ^ Carl Hewitt; Peter Bishop; Richard Steiger (1973). "A Universal Modular Actor Formalism for Artificial Intelligence". IJCAI. {{cite journal}}: Cite journal requires |journal= (help)
  8. ^ Kay, Alan. "prototypes vs classes was: Re: Sun's HotSpot". lists.squeakfoundation.org. Retrieved 2 January 2014.
  9. ^ "Using Message Passing to Transfer Data Between Threads - The Rust Programming Language". Rust-lang.org.

Further reading

Read other articles:

Pour les articles homonymes, voir Démétrios et Dimitri. Démétrios de ThessaloniqueFonctionSénateur romainBiographieNaissance Entre 270 et 281ThessaloniqueDécès Vers 306Thessalonique ou Sremska MitrovicaNom dans la langue maternelle Δημήτριος της ΘεσσαλονίκηςÉpoque Bas-Empire romain, Antiquité tardiveActivités Militaire, religieux ou religieuse orthodoxe, soldatAutres informationsÉtape de canonisation Mégalomartyr, saint, myroblyte (en)Grade militaire SoldatFê…

Louis GueuningBiographieNaissance 5 mars 1898Braine-le-ComteDécès 11 novembre 1971 (à 73 ans)AthNationalité belgeActivité Homme politiquemodifier - modifier le code - modifier Wikidata Louis Gueuning, né le 5 mars 1898 à Braine-le-Comte et mort à Ath le 11 novembre 1971[1], est un professeur et homme politique belge. Professeur de lettres classiques à Arlon, Soignies et Leeuw-Saint-Pierre, il fut en politique engagé au sein du Verdinaso en premier et au sein du Groupe Gueuning apr…

Disambiguazione – Se stai cercando altri significati, vedi Ragusa (disambigua). Ragusacomune (dettagli) Ragusa – VedutaRagusa Ibla LocalizzazioneStato Italia Regione Sicilia Libero consorzio comunale Ragusa AmministrazioneSindacoGiuseppe Cassì (Indipendente di centro) dal 27-6-2018 (2º mandato dal 7-7-2023) TerritorioCoordinate36°55′30″N 14°43′50″E / 36.925°N 14.730556°E36.925; 14.730556Coordinate: 36°55′30″N 14°43′50″E…

Министерство природных ресурсов и экологии Российской Федерациисокращённо: Минприроды России Общая информация Страна  Россия Юрисдикция Россия Дата создания 12 мая 2008 Предшественники Министерство природных ресурсов Российской Федерации (1996—1998)Министерство охраны о…

Флаг гордости бисексуалов Бисексуальность      Сексуальные ориентации Бисексуальность Пансексуальность Полисексуальность Моносексуальность Сексуальные идентичности Би-любопытство Гетерогибкость и гомогибкость Сексуальная текучесть Исследования Шка…

Racism in German history is inextricably linked to the Herero and Namaqua genocide in colonial times. Racism reached its peak during the Nazi regime which eventually led to a program of systematic state-sponsored murder known as The Holocaust. According to reports by the European Commission, milder forms of racism are still present in parts of German society. Currently the racism has been mainly directed towards Asian and African countries[1] by both the state and through the citizens wh…

此條目可参照外語維基百科相應條目来扩充。若您熟悉来源语言和主题,请协助参考外语维基百科扩充条目。请勿直接提交机械翻译,也不要翻译不可靠、低品质内容。依版权协议,译文需在编辑摘要注明来源,或于讨论页顶部标记{{Translated page}}标签。 Osagyefo克瓦米·恩克鲁玛第三届非洲联盟主席任期1965年10月21日—1966年2月24日前任贾迈勒·阿卜杜-纳赛尔继任约瑟夫·亚瑟·安…

2016年美國總統選舉 ← 2012 2016年11月8日 2020 → 538個選舉人團席位獲勝需270票民意調查投票率55.7%[1][2] ▲ 0.8 %   获提名人 唐納·川普 希拉莉·克林頓 政党 共和黨 民主党 家鄉州 紐約州 紐約州 竞选搭档 迈克·彭斯 蒂姆·凱恩 选举人票 304[3][4][註 1] 227[5] 胜出州/省 30 + 緬-2 20 + DC 民選得票 62,984,828[6] 65,853,514[6] 得…

Title in the Peerage of Ireland Baron Muskerry is a title in the Peerage of Ireland. It was created in 1781 for Sir Robert Deane, 6th Baronet. He had previously represented County Cork in the Irish House of Commons. His great-grandson, the fourth Baron, sat in the House of Lords as an Irish representative peer from 1892 to 1929. On the death in 1954 of his younger son, the sixth Baron, this line of the family failed. The late Baron was succeeded by his first cousin once removed, the seventh Baro…

Sports events held in San Salvador, El Salvador XIX Central American and Caribbean GamesHost citySan SalvadorCountryEl SalvadorNations31Athletes4,301Events32OpeningNovember 22ClosingDecember 8Opened byFrancisco Flores Pérez[1]Athlete's OathPrince Albert of Monaco[1]Torch lighterFrancisco Flores Pérez[1]Main venueEstadio Nacional Flor Blanca[1]← 1998 Maracaibo2006 Cartagena → The 19th Central American and Caribbean Games were held in San Sal…

نادي التهامي السعودي الاسم الكامل نادي التهامي الرياضي السعودي اللقب عميد الجنوب المؤسس محمد سالم باعشن[1] تأسس عام 1948 م - 1368 هـ الملعب ملعب مدينة الملك فيصل الرياضيةجيزان  السعودية(السعة: 10,000) البلد السعودية  الدوري دوري الدرجة الرابعة السعودي 2021 - 2022 2021 - 2022 الإدارة …

Mahanayaka (also spelled as Maha Nayaka, Maha Nayake) theros are high-ranking Buddhist monks who oversee and regulate the Buddhist clergy in Theravada Buddhist countries. The title Maha Nayaka translates to English as 'Great Leader' and it is considered to be a very important position held by a monk in a Theravada Buddhist country. It is usually bestowed upon the senior Buddhist monks who are appointed the chief prelates of monastic fraternities known as Nikayas. Sri Lankan tradition In Sri Lank…

Melon Music AwardsDeskripsiKesempurnaan dalam musikNegara Korea SelatanDipersembahkan olehLOEN Entertainment, Inc.Diberikan perdana2005Situs webwww.melon.com/mma/index.htmSiaran televisi/radioSaluranCU Media (2009)MBC Plus (2010-sekarang) (sejak 2012 termasuk MBC Music) QQ Music/QQLive (2016-sekarang) Music On! TV (2016-sekarang) JOOX Music (2016-sekarang) Melon Music Awards adalah salah satu acara penghargaan musik utama yang digelar setiap tahun di Korea Selatan dan diatur oleh LOEN Enter…

Property tort For other uses, see Conversion (disambiguation). Part of the common law seriesTort law (Outline) Trespass to the person Assault Battery False imprisonment Intentional infliction of emotional distress Property torts Trespass land chattels Conversion Dignitary torts Appropriation Defamation Slander Libel False light Invasion of privacy Intrusion on seclusion Breach of confidence Abuse of process Malicious prosecution Sexual torts Alienation of affections Criminal conversation Seducti…

Term for any American state where neither party's candidate for election has overwhelming support Map of states by margin in the 2020 United States presidential election, relative to the national popular vote margin (4.5% in favor of Biden).Map Legend:  Partisan lean of under 5 points toward the Democratic presidential nominee (Incumbent president Joe Biden)   Partisan lean of under 5 points toward the Republican presidential nominee (former president Donald Trump)  …

Бирка календарная казаков Восточного Забайкалья. XIX век Болгарский деревянный календарь. 1914 Наро́дные календари́ у славя́н — исторически сложившиеся у славянских народов к позднему средневековью системы членения, счёта и регламентации годового времени, организующие…

Map showing world adoption of the MUTCD[citation needed]  Adopted national MUTCD   Adopted national MUTCD with state supplement   Adopted state-specific MUTCD  Adopted a country-specific equivalent to the MUTCD  Adopted a mixture of the Vienna Convention and MUTCD Road signs used by countries in the Americas are significantly influenced by the Manual on Uniform Traffic Control Devices (MUTCD), first released in 1935, reflecting the influe…

1176 battle between the Byzantine Empire and the Seljuk Turks Battle of MyriokephalonPart of the Byzantine–Seljuq WarsThis image by Gustave Doré shows the Turkish ambush at the pass of Myriokephalon.Date17 September 1176LocationPass of Tzivritze, near the fortress of Myriokephalon (not presently identified), west of Konya, AnatoliaResult Seljuk victory Military balance maintained[1]Belligerents Byzantine EmpireHungaryPrincipality of AntiochPrincipality of Serbia Sultanate of RumComman…

Canadian sculptor Elizabeth Wyn WoodBornOctober 8, 1903Orillia, Ontario, CanadaDiedJanuary 27, 1966 (aged 62)Willowdale, Ontario, CanadaEducationOntario College of ArtArt Students League of New YorkKnown forSculptorMovementArt DecoSpouseEmanuel Hahn (m.1926) Elizabeth Winnifred Wood RCA (October 8, 1903 – January 27, 1966), known as Elizabeth Wyn Wood, was a Canadian sculptor and advocate of art education. A notable figure in Canadian sculpture, she is primarily known for her modernist in…

الأدهقراطية لفظ منحوت من أد هوك باللاتينية أي من أجله، قياسا بلفظ البيرقراطية وهو، بعكسه، يعبر به عن نوع بسيط من الإدارة يبتغى منه حل المشاكل الطارئة بدل التخطيط لتجنبها.[1][2][3] مراجع ^ Bennis، Warren (1968). The Temporary Society. New York: Harper & Row. ^ Dolan، Timothy (2010). Revisiting Adhocracy: From rhetorical revi…