aboutsummaryrefslogtreecommitdiffstats
blob: 1659eea8888452904efea76fb955d13a19f754c4 (plain)
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
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Why does it work and why is it safe?</title>
<link href="book.css" rel="stylesheet" type="text/css">
<meta content="DocBook XSL Stylesheets V1.75.1" name="generator">
<link rel="home" href="index.html" title="eTrice User Guide">
<link rel="up" href="TutorialPedestrianLightsJava.html" title="Tutorial Pedestrian Lights (Java)">
<link rel="prev" href="Setupthemodel.html" title="Setup the model">
<link rel="next" href="SettinguptheWorkspaceforCProjects.html" title="Setting up the Workspace for C Projects">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Why does it work and why is it safe?</h1>
<div class="section" title="Why does it work and why is it safe?">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Whydoesitworkandwhyisitsafe"></a>Why does it work and why is it safe?</h2>
</div>
</div>
</div>
<p>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="bold"><strong>run to completion</strong></span> semantic. To answer this question, take a look at the 
				<span class="emphasis"><em>MessageService.java</em></span> from the runtime environment. There you will find the receive method which puts each message into the queue. 
			</p>
<div class="literallayout">
<p>
<code class="code">&nbsp;&nbsp;&nbsp;&nbsp;@Override<br>
&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;synchronized&nbsp;void&nbsp;receive(Message&nbsp;msg)&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(msg!=null)&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;messageQueue.push(msg);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;notifyAll();&nbsp;//&nbsp;wake&nbsp;up&nbsp;thread&nbsp;to&nbsp;compute&nbsp;message<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>

</code>
</p>
</div>
<div class="blockquote">
<blockquote class="blockquote">
<p></p>
</blockquote>
</div>
<p>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>
</div>
</body>
</html>