メッセージ (コンピュータ)

計算機科学におけるメッセージ (: message) とは、情報の伝達を目的とする、順序付けられた文字列である。JISでは、情報理論および通信理論におけるmessageの訳語として通報[1]という用語が割り当てられている[注釈 1]

メッセージパッシング (: message passing) とは、並行計算並列計算オブジェクト指向プロセス間通信で使われる通信方式である。プロセスもしくはオブジェクトといったモデルではメッセージ(ゼロ以上のバイト、複雑なデータ構造、プログラムコードも含む)を送ったり受けたりできる。メッセージを待つことによって同期することもできる。メッセージパッシングに基づく主なモデルとしてアクターモデルプロセス代数がある。

概要

メッセージパッシングは、ひとつもしくは多くの受信者 (receiver) に対して送信者 (sender) がデータを配送できる通信方法である。通報の形として遠隔メソッド呼び出し(: remote method invocation; RMI)、シグナル、データパケットなどがある。メッセージパッシング機構を設計するとき、下記のような方針から設計方針を選択する。

重要な理論上の基礎であるアクターモデルプロセス計算といった並行計算はメッセージパッシングを基礎としている。メッセージパッシングを使った並行システムは、言語内の機能としてメッセージパッシングする場合と言語からの一連のライブラリ呼び出しで実現する場合がある。 前者の例は多くの分散オブジェクトシステムが含まれる。後者の例としては、カーネルとサーバブロック間でメッセージをやりとりするマイクロカーネルオペレーティングシステムや、高性能計算における Message Passing Interface がある。メッセージパッシングの概念は、グラフモデル上のベイズ推定などでも使われている。

オペレーティングシステムにおけるメッセージ

Microsoft Windowsなどのオペレーティングシステムにおいて、メッセージとは、オペレーティングシステム上で動くアプリケーションに対して、オペレーティングシステムが管理しているデバイスあるいは別のプロセススレッドからの入力を伝えるために送られる、ひとかたまりのデータ集合のことである。メッセージを送受信することを通知とも呼ぶ。

オペレーティングシステムはメッセージをメッセージキューに保管し、アプリケーションはメッセージキューに保管されていたメッセージを受け取り、それを元に処理を行う。例えば「画面座標 (10, 20) の位置をマウスで左クリック」という情報をオペレーティングシステムが感知した場合、オペレーティングシステムはその情報をメッセージキューに保管する。アプリケーションはそのメッセージを受け取って対応した処理を行う。

アプリケーションは常にオペレーティングシステムからのメッセージを待機するようなイベント駆動方式プログラムになっており、この一連のプログラムの機構をメッセージループという。メッセージキューを定期的に監視・確認するポーリング方式でメッセージループが実装されることもある。

メッセージパッシングシステムとモデル

分散オブジェクトや ONC RPCCORBAJava RMIDCOMSOAP.NET RemotingWCF、CTOS[要説明]QNX Neutrino RTOSOpenBinderD-Bus のような遠隔メソッド呼び出しあるいはそれに類するものはメッセージパッシングシステムである。メッセージパッシングシステムは共有のないシステムと呼ばれている。なぜならば、メッセージパッシング型のシステムは、メッセージという抽象化によってその下位に存在する状態変化や実装などを隠蔽するものだからである。

メッセージパッシングモデルはデータを端末(アクター、プロセス、スレッドなど)に送信するような通達方式で、プログラミング言語で典型的に定義されている。そのようなメッセージングはSOAPによってWebサービスの中で使われている。この考え方はパケットより大きく、任意に信頼性や耐久性や安全性やトランザクションを追加したものを除く高いレベルのメッセージデータグラムである。メッセージもまた一般的に同じ向きのプロセス間通信に使われる。また別の一般的に使われる技術はストリームもしくはパイプで、そのようなデータは初歩的なデータアイテムの一連として送信される(仮想回線の高等レベルでは)。

同期通信と非同期通信

同期メッセージパッシングシステムでは送信者と受信者がお互いにメッセージの転送を待つ。つまり、送信者は受信者がメッセージを受信するまでプログラムを再開できない。

同期通信は二つの利点がある。利点の一つ目はメッセージ転送において送信者と受信者で同期をとるため、プログラムを単純化できることである。利点の二つ目はバッファを必要としないことである。メッセージはいつでも受信側に保存される。なぜならば、送信者は受信者の準備が完了するまで送信を待つためである。

非同期メッセージパッシングシステムは受信者から送信者に準備ができる時間を待たずにメッセージを送る。非同期通信の利点はお互いに待つことがないので、お互いの計算処理をオーバーラップして行える。

同期通信は送信者がいつも受信者が続ける前にメッセージを応答したことを確実にする非同期通信をベースに築かれている。

非同期通信はバッファを必要とするが、そのバッファが満杯になると問題の原因になる。送信者をブロックするか今後のメッセージを切り捨てるか判断をしなければならない。送信者をブロックすれば、予期しないデッドロックを引き起こすかもしれない。メッセージを捨てた場合通信の信頼性は無くなる。

メッセージパッシングと関数呼び出しの比較

メッセージパッシングはプログラム間で情報を受け渡すためのもうひとつの通信方法、つまりCallと対比されるべきである。伝統的なCallにおいては、引数は典型的には一つ以上の汎用レジスタまたは引数のアドレスを内包しているパラメータリストを通じて、"callee" すなわち「呼び出し先」(receiver: 受信者)に渡される。この通信形式はメッセージパッシングと比較して少なくとも三つの大きな違いがある。

メッセージパッシングではどの引数も、新しいメッセージの中にコピーするのに十分なメモリを余計に必要とする。これはオリジナルの引数のサイズの大小によらない。したがって、もし引数のうちのひとつがwebページを記述する10,000オクテットHTML文字列だとすると、受信プログラム(ローカルプログラムでないならば)に完全にコピーされなければならない(そしてさらに送信されなければならないだろう)。 対照的に、callの手法ならば、それぞれの引数に対して4から8バイト分のアドレスしか必要としない。さらに汎用レジスタならば追加の記憶領域はゼロであり、送信時間もゼロである。これはもちろん分散システムでは不可能である。というのも、呼び出し元 (caller) のアドレス空間における(絶対)アドレスは、リモートプログラムでは通常意味をなさないからである。ただし、もしcalleeが前もってcallerのメモリの正確な(少なくとも一部の)コピーを有していたならば、相対アドレスが利用できるかもしれない。

メッセージパッシングスタイルの例

  • actor model implementation
  • amorphous computing
  • antiobjects
  • flow-based programming
  • SOAP
  • Smalltalk

他のプログラミングモデルへの影響

オブジェクト指向の幾つかの専門用語の中にメッセージはオブジェクトにコントロールを渡すという意味で使われる。もしオブジェクトがそのメッセージに応答したならばそれはそのメッセージに対するメソッドを持っている。詳しくはオブジェクト指向プログラミングを参照すること。

純粋なオブジェクト指向ではメッセージパッシングは排他的にダイナミックディスパッチに投げられる様に機能する。

同じメッセージを二回同じオブジェクトに送信した場合、普通そのメソッドを二回請求する結果となる。もし、名前と引数が同じならば二つのメッセージは同じメッセージタイプと考えられている。

オブジェクトは自分のメソッド本体から他のオブジェクトにメッセージを送信できる。メッセージパッシングシステムの中で、究極遅延束縛 (: extreme late binding) が可能である。

アラン・ケイ は彼の視点のオブジェクト指向プログラミングの中ではオブジェクトよりも重要なコンセプトだが、人々はよくそのポイントと場所を見逃し、オブジェクト自体に重点をおきすぎ、十分メッセージをその間に送ってないと主張した[3]。ライブ分散オブジェクトのプログラミングモデルはこの所見を踏まえて作られた。それは分散型データフローのコンセプトを使い複雑な分散型システムの振る舞いをメッセージパターンの(高レベル)機能スタイル仕様書とみなした。

幾つかの言語では、あるオブジェクトがメッセージを処理するメソッドを持っていなくとも、それを持っているであろう他のオブジェクトを知っている場合に、メソッド呼び出しを1つのオブジェクトから他のオブジェクトに転送、もしく委譲することをサポートしている。メッセージ転送を参照。

1977年、カール・ヒューイットは、計算制御構造は「メッセージパッシングのパターン」と見ることができると主張した[4]

Smalltalk系統の言語におけるメッセージ

Smalltalk及びSelfObjective-CなどSmalltalk系統のオブジェクト指向言語においてメッセージは、メソッドを起動するセレクターと引数の組み合わせ、およびセレクターと引数を合わせたオブジェクトを示す[5]

result := receiver + 1.
result := receiver selector.
result := receiver selector: 0 and: 2.

例えば上記の式であれば、+ 1selectorselector: 0 and: 2が前者のメッセージとなる。C++系統の言語におけるメンバー関数の呼び出しに類似しているが、Smalltalk系統の言語はメンバー関数の実装部分にあたるメソッドとメッセージは独立した存在であり、メッセージはクラスに紐づかない。また、必ずしもセレクターとメソッドは一対一ではなく一つのメソッドに複数のセレクターを取り付けることができ、セレクターが異なるメッセージを同じメソッドで処理することができる[注釈 2]。また、メッセージと対応したメソッドが一切存在しないオブジェクトでもメッセージを受信することが可能になっている[注釈 3]

脚注

注釈

  1. ^ コンピュータと人間との対話のため、単に画面等へ表示される文字列を指す場合は、通信文または通知[2]と訳されることもある。エラーメッセージ (: error message) は「誤り通知」となる。
  2. ^ 例えばSmalltalkであれば#addSelector:withMethod:で追加できる[6]
  3. ^ 例えばSmalltalkであればメソッドが存在しないメッセージを#doesNotUnderstand:で受信することができる。メッセージ転送を参照。

出典

関連項目

参考文献

Read other articles:

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] 得…

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] 得…

Not to be confused with Ein Qiniyye or Ain Qinia. Local Development Committee in Ramallah and al-Bireh, State of PalestineEin QiniyaLocal Development CommitteeArabic transcription(s) • Arabicعين قينيا • LatinAyn Kiniya (official)Ein Qinya (unofficial)Ein Qiniya 2019Ein QiniyaLocation of Ein Qiniya within PalestineShow map of the West BankEin QiniyaEin Qiniya (State of Palestine)Show map of State of PalestineCoordinates: 31°55′37″N 35°08′56″E…

Ethnic group and federally-recognized tribe in Arizona, United States This article is about the Yuma, the Native American people in the United States. For their language, see Quechan language. For the South American language, see Quechuan languages. Yuman redirects here. For the settlement in Butte County, California, see Yuman, California. For the Italian singer-songwriter, see Yuman (singer). Not to be confused with Quecha or Quechua. This article needs additional citations for verification. P…

Indigenous people of the Northeastern Woodlands For other uses, see Lenape (disambiguation). Delaware Indians and Delaware people redirect here. For other American Indians from present-day Delaware, see Category:Native American tribes in Delaware. For individual people from the state of Delaware, see List of people from Delaware. LenapeDelaware peopleLënapeyokThe Lenape territory, known as Lenapehoking, as of the 16th and 17th centuries, with speakers of Munsee (north), Unalachtigo (center), an…

NATCOIndustryTransportFounded1974HeadquartersGilgit, PakistanKey peopleTahir Hussain (Chairman) Muhammad Saeedullah Yousafzai (Managing Director)Websitewww.natco.gov.pk NATCO bus at Balakot, Mansehra NATCO bus at bus stand in Rawalpindi Northern Areas Transport Corporation or NATCO (Urdu: ٹرانسپورٹ کارپوریشن برائے شمالی علاقہ جات) is the largest transport company in Gilgit-Baltistan, Pakistan and throughout the Karakoram Highway. NATCO is providing its service…

Uncrewed spaceflight program by NASA Part of a series on theUnited States space program NASAU.S. Space Force Human spaceflight programs Mercury Gemini Apollo Skylab Space Shuttle Shuttle–Mir International Space Station Commercial Crew Constellation Artemis Lunar Gateway Robotic spaceflight programs CRS Explorers GLS Large Strategic Lunar Orbiter Lunar Precursor Mariner Mars Exploration New Millennium Pioneer Planetary Missions Discovery New Frontiers Solar System Exploration Planetary Observer…

Copa América 2019Copa América Brasil 2019Vibra o Continente(Vibra el Continente)Inggris: Rocking the ContinentInformasi turnamenTuan rumahBrasilJadwalpenyelenggaraan14 Juni – 7 JuliJumlahtim peserta12 (dari 2 konfederasi)Tempatpenyelenggaraan6 (di 5 kota)Hasil turnamenJuara Brasil (gelar ke-9)Tempat kedua PeruTempat ketiga ArgentinaTempat keempat ChiliStatistik turnamenJumlahpertandingan26Jumlah gol60 (2,31 per pertandingan)Jumlahpenonton855.861 (32.91…

Historical legal principleThis article's tone or style may not reflect the encyclopedic tone used on Wikipedia. See Wikipedia's guide to writing better articles for suggestions. (February 2024) (Learn how and when to remove this message) Charles V, Holy Roman Emperor and King of Spain, instructed his brother to settle disputes relating to religion and territory at the Diet of Augsburg in 1555. Cuius regio, eius religio (Ecclesiastical Latin: [ˈku.jus ˈre.d͡ʒi.o ˈe.jus reˈli.d͡ʒi.o …

People in Finland of full or partial African ancestry Ethnic group African diaspora in FinlandTotal populationAt least 57,496[a](1.0% of the population of Finland in 2020)[b]Regions with significant populationsMostly in Uusimaa (Helsinki (Kallahti), Espoo, Vantaa), Turku, Vaasa and PorvooLanguagesNumerous; FinnishAfroasiatic languagesNiger–Congo languagesNilo-Saharan languagesIndo-European languages The African diaspora in Finland (Finnish: afrikkalaisten diaspora Suomessa) ref…

Protected area in New Jersey, United States 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: Great Swamp National Wildlife Refuge – news · newspapers · books · scholar · JSTOR (September 2017) (Learn how and when to remove this message) Great Swamp National Wildlife RefugeIUCN category IV (habitat/species manage…

American middle-distance runner Reginald James Pearman III (May 23, 1924 – June 11, 2012) was an American middle distance runner who competed in the 1952 Summer Olympics. Born to Bermudian immigrants in Manhattan, he served in the United States Army during World War II and the Korean War. Following his athletic career, he also worked for the Peace Corps and United States Office of Education.[1][2] He graduated from Newtown High School and New York University.[3][4&#…

Baraita Rabbinic literatureTalmud Readers by Adolf Behrman Talmudic literature Tannaitic Mishnah Tosefta Amoraic (Gemara) Jerusalem Talmud Babylonian Talmud Later Minor Tractates Halakhic Midrash Exodus Mekhilta of Rabbi Ishmael Mekhilta of Rabbi Shimon bar Yochai Leviticus Sifra (Torat Kohanim) Numbers and Deuteronomy Sifre Sifrei Zutta on Numbers (Mekhilta le-Sefer Devarim) Aggadic Midrash Tannaitic Seder Olam Rabbah Alphabet of Rabbi Akiva Baraita of the Forty-nine Rules Baraita on the Thirty…

هيئة الإذاعة الكندية   معلومات عامة النوع شبكة تلفزيونتلفزيون أرضيشبكة راديوويب المدير هوبرت لاكرولويس لالاند تاريخ التأسيس 1936 تاريخ أول بث 2 نوفمبر، 1936 البلد كندا اللغة لغة إنجليزيةلغة فرنسية المقر الرسمي أوتاوا، كندا الموقع الرسمي الموقع الرسمي صفحة فيسبوك cbc  صفحة …

Sporting event delegationTrinidad and Tobago at the2017 World Championships in AthleticsFlag of Trinidad and TobagoWA codeTTONational federationNational Association of Athletics Administrations of Trinidad & TobagoWebsitettnaaa.orgin London, United Kingdom4–13 August 2017Competitors20 (12 men and 8 women) in 13 eventsMedalsRanked =17th Gold 1 Silver 0 Bronze 1 Total 2 World Championships in Athletics appearances198319871991199319951997199920012003200520072009201120132015201720192…

2008 UK local government election Map of the results of the 2008 Carlisle City Council election. Conservatives in blue, Labour in red, Liberal Democrats in yellow and independent in light grey. Wards in dark grey were not contested in 2008. The 2008 Carlisle City Council election took place on 1 May 2008 to elect members of Carlisle District Council in Cumbria, England. One third of the council was up for election and the council stayed under no overall control.[1] After the election, th…

Nederlands landskampioenschap 1914-1915 Competizione Nederlands landskampioenschap Sport Calcio Edizione 27ª Organizzatore KNVB Luogo  Paesi Bassi Partecipanti 18 Cronologia della competizione 1913-14 1915-16 Manuale Al campionato parteciparono diciotto squadre e lo Sparta Rotterdam vinse il titolo. Indice 1 Est 2 Ovest 3 Finale per il titolo 4 Spareggio per il titolo 5 Collegamenti esterni Est Club G V N P GF GS Punti DR 1 Vitesse 14 8 4 2 44 22 20 +22 Qualificata per la finale. 2 Go Ahea…

Royal Navy officer (1656–1694) For the British general, see Sir Francis Wheler, 10th Baronet. Sir Francis WhelerBorn1656 (1656)DiedFebruary 19, 1694(1694-02-19) (aged 37–38)HMS Sussex, off GibraltarAllegianceKingdom of EnglandService/branchRoyal NavyRankRear-Admiral of the RedCommandsHMS NonsuchHMS KingfisherHMS TygerHMS CenturionHMS KentHMS AlbemarleJamaica StationBattles/warsNine Years' War Battle of Beachy Head Battle of Barfleur AwardsKnight B…

Voce principale: Associazione Calcio Mestre. Associazione Calcio MestreStagione 1981-1982Sport calcio Squadra Mestre Allenatore Giorgio Rumignani Presidente Guido Robazza Serie C22º posto nel girone B. Promosso in Serie C1. Coppa Italia Serie C1º turno, girone 11. Maggiori presenzeCampionato: Tonetto, Trevisanello (34) Miglior marcatoreCampionato: Rombolotto (10) StadioStadio Francesco Baracca 1980-1981 1982-1983 Si invita a seguire il modello di voce Questa voce raccoglie le informazioni…

Method for interpreting data in digital storage systems In computer data storage, partial-response maximum-likelihood (PRML) is a method for recovering the digital data from the weak analog read-back signal picked up by the head of a magnetic disk drive or tape drive. PRML was introduced to recover data more reliably or at a greater areal-density than earlier simpler schemes such as peak-detection.[1] These advances are important because most of the digital data in the world is stored us…