Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ab08cab50f397bb3b6c0535de77dc78ae65ef8b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?xml version="1.0" encoding="iso-8859-1" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<!--http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd-->  
<html xmlns="http://www.w3.org/1999/xhtml"  
> 
<head><title>Why does it work and why is it safe?</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<!-- xhtml,3,next,html --> 
<meta name="src" content="etrice-doc.tex" /> 
<meta name="date" content="2013-06-13 15:30:00" /> 
<link rel="stylesheet" type="text/css" href="etrice-doc.css" /> 
</head><body 
>
<!--l. 97--><div class="crosslinks"><p class="noindent">[<a 
href="etrice-docch9.html" >next</a>] [<a 
href="etrice-docse27.html" >prev</a>] [<a 
href="etrice-docse27.html#tailetrice-docse27.html" >prev-tail</a>] [<a 
href="#tailetrice-docse28.html">tail</a>] [<a 
href="etrice-docch8.html#etrice-docse28.html" >up</a>] </p></div>
<h3 class="sectionHead"><span class="titlemark">8.3   </span> <a 
 id="x38-590008.3"></a>Why does it work and why is it safe?</h3>
<!--l. 99--><p class="noindent" >The tutorial shows that it is generally possible to use every port from outside the model as long as the port
knows its peer. This is guaranteed by describing protocol and the complete structure (especially the bindings)
within the model. The only remaining question is: Why is it safe and does not violate the <span 
class="ec-lmssbx-10">run to</span>
<span 
class="ec-lmssbx-10">completion </span>semantic. To answer this question, take a look at the <span 
class="ec-lmsso-10">MessageService.java </span>from the
runtime environment. There you will find the receive method which puts each message into the
queue.
                                                                                 
                                                                                 
</p>
<div class="verbatim" id="verbatim-18">
&#x00A0;&#x00A0;&#x00A0;&#x00A0;@Override
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;public&#x00A0;synchronized&#x00A0;void&#x00A0;receive(Message&#x00A0;msg)&#x00A0;{
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;if&#x00A0;(msg!=null)&#x00A0;{
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;messageQueue.push(msg);
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;notifyAll();&#x00A0;//&#x00A0;wake&#x00A0;up&#x00A0;thread&#x00A0;to&#x00A0;compute&#x00A0;message
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;}
&#x00A0;<br />&#x00A0;&#x00A0;&#x00A0;&#x00A0;}
</div>
<!--l. 114--><p class="nopar" >
</p><!--l. 116--><p class="noindent" >This method is synchronized. That means, regardless who sends the message, the queue is secured. If we later
on (e.g. for performance reasons in C/C++) distinguish between internal and external senders (same thread or
not), care must be taken to use the external (secure) queue.
                                                                                 
                                                                                 
                                                                                 
                                                                                 
                                                                                 
                                                                                 
</p>
<!--l. 1--><div class="crosslinks"><p class="noindent">[<a 
href="etrice-docch9.html" >next</a>] [<a 
href="etrice-docse27.html" >prev</a>] [<a 
href="etrice-docse27.html#tailetrice-docse27.html" >prev-tail</a>] [<a 
href="etrice-docse28.html" >front</a>] [<a 
href="etrice-docch8.html#etrice-docse28.html" >up</a>] </p></div>
<!--l. 1--><p class="noindent" ><a 
 id="tailetrice-docse28.html"></a> </p> 
</body></html> 

Back to the top