📄 node57.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>5.6 Asynchronous Communication</TITLE>
</HEAD>
<BODY>
<meta name="description" value="5.6 Asynchronous Communication">
<meta name="keywords" value="book">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html2619 HREF="node56.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node56.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html2627 HREF="node58.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node58.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html2625 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html2629 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html2630 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html2628 HREF="node58.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node58.html">5.7 Determinism</A>
<B>Up:</B> <A NAME=tex2html2626 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
</A>
<B> Previous:</B> <A NAME=tex2html2620 HREF="node56.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node56.html">5.5 Communication</A>
<BR><HR><P>
<H1><A NAME=SECTION03260000000000000000>5.6 Asynchronous Communication</A></H1>
<P>
<A NAME=7346> </A>
Recall that the need for asynchronous communication can arise when the
<A NAME=7347> </A>
tasks involved in a computation must access elements of a shared data
structure in an unstructured manner (Section <A HREF="node17.html#seccommas" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node17.html#seccommas">2.3.4</A>). This
<A NAME=7349> </A>
requirement can be satisfied in CC++
in three different ways:
<OL><LI>
The shared data structure can be encapsulated in a set of specialized
<em> data tasks
</em> to which read and write requests are directed by
using channel operations.
<P>
<LI>
The shared data structure can be distributed among the computation
tasks. As discussed in Section <A HREF="node17.html#seccommas" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node17.html#seccommas">2.3.4</A>, each computation
task must then <em> poll
</em> periodically for pending requests. For
example, we can extend the <tt> Queue</tt> class of
Program <A HREF="node56.html#progccch0" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node56.html#progccch0">5.6</A> to support a poll operation. The <tt>
IntQData</tt> structure is augmented with a full/empty field, which is
initialized to empty when a list element is created and set to full
when a data value is placed in the list element. The poll function
simply checks the status of this field in the list element at the head
of the queue.
<P>
<LI>
A third implementation approach exploits CC++
's RPC mechanism more
directly. The shared data structure is distributed among the
computation tasks. However, rather than sending a message on a
channel, a task accesses data in another processor object by making an
RPC to an appropriate member function. (The <tt> get_x</tt> function of
Program <A HREF="node52.html#progccex2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node52.html#progccex2">5.1</A> is a simple example of the sort of RPC we
might write.)
</OL>
The third approach is explored in a case study in
Section <A HREF="node63.html#secccfock" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#secccfock">5.12</A>.
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html2619 HREF="node56.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node56.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html2627 HREF="node58.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node58.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html2625 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html2629 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html2630 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html2628 HREF="node58.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node58.html">5.7 Determinism</A>
<B>Up:</B> <A NAME=tex2html2626 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
</A>
<B> Previous:</B> <A NAME=tex2html2620 HREF="node56.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node56.html">5.5 Communication</A>
<BR><HR><P>
<P><ADDRESS>
<I>© Copyright 1995 by <A href="msgs0.htm#6" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#6">Ian Foster</a></I>
</ADDRESS>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -