<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://so.v2.cs.unibo.it/wiki/index.php?action=history&amp;feed=atom&amp;title=ProvaPratica_2011.01.19</id>
	<title>ProvaPratica 2011.01.19 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://so.v2.cs.unibo.it/wiki/index.php?action=history&amp;feed=atom&amp;title=ProvaPratica_2011.01.19"/>
	<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;action=history"/>
	<updated>2026-06-20T18:18:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=726&amp;oldid=prev</id>
		<title>TomOgn at 11:15, 14 May 2014</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=726&amp;oldid=prev"/>
		<updated>2014-05-14T11:15:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 11:15, 14 May 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l170&quot; &gt;Line 170:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 170:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	exit(EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	exit(EXIT_FAILURE);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=Esercizio 3=&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Esercizio 3==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Esercizio 3==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>TomOgn</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=724&amp;oldid=prev</id>
		<title>TomOgn at 08:47, 14 May 2014</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=724&amp;oldid=prev"/>
		<updated>2014-05-14T08:47:07Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:47, 14 May 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l172&quot; &gt;Line 172:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 172:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Esercizio 3=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Esercizio 3=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;syntaxhighlight lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;def ssend2(m, d1, d2):&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	msg = ( SND, getpid(), d1, d2, m )&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	asend(msg, server)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	return arecv(server)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;def sreceive():&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	msg = ( RCV, getpid(), None, None, None )&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	asend(msg, server)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	return arecv(server)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;def server():&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;	while True:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;		flag, src, d1, d2, msg = arecv(*)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;		if flag == RCV:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			msg, sender, _, _ = dbSnd.retrieve(query = '(?, ?, src, ?) or (?, ?, ?, src)')&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			if msg:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(msg, src)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(src, sender)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			else:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				dbRcv.insert(src)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;		else:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			if dbRcv.retrieve(d1):&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(msg, d1)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(d1, src)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			elif dbRcv.retrieve(d2):&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(msg, d2)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				asend(d2, src)&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;			else:&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;				dbSnd.insert((msg, src, d1, d2))&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Esercizio 3==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Esercizio 3==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>TomOgn</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=723&amp;oldid=prev</id>
		<title>TomOgn: Created page with &quot;=[http://www.cs.unibo.it/~renzo/so/pratiche/2011.01.19.pdf TESTO COMPITO]= =Esercizio 1= &lt;syntaxhighlight lang=&quot;C&quot;&gt; // Dependencies #include &quot;../const.h&quot; #include &lt;stdio.h&gt; #i...&quot;</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.01.19&amp;diff=723&amp;oldid=prev"/>
		<updated>2014-05-14T08:46:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=[http://www.cs.unibo.it/~renzo/so/pratiche/2011.01.19.pdf TESTO COMPITO]= =Esercizio 1= &amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt; // Dependencies #include &amp;quot;../const.h&amp;quot; #include &amp;lt;stdio.h&amp;gt; #i...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=[http://www.cs.unibo.it/~renzo/so/pratiche/2011.01.19.pdf TESTO COMPITO]=&lt;br /&gt;
=Esercizio 1=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
// Dependencies&lt;br /&gt;
#include &amp;quot;../const.h&amp;quot;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;getopt.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Function declarations&lt;br /&gt;
static inline void printAndDie(const char *msg);&lt;br /&gt;
static inline void errorAndDie(const char *msg);&lt;br /&gt;
static void redirectAndRun(char *outFile, char *inFile, char *path, char *command[]);&lt;br /&gt;
static void parseArguments(int argc, char **argv);&lt;br /&gt;
&lt;br /&gt;
// Entry point&lt;br /&gt;
extern void run(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	parseArguments(argc, argv);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Parse arguments accordingly to a given set of options.&lt;br /&gt;
 * Input: argc, the argument counter&lt;br /&gt;
 *        argv, the argument vector&lt;br /&gt;
 */&lt;br /&gt;
static void parseArguments(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
	int i, j, result;&lt;br /&gt;
	char **command;&lt;br /&gt;
	char *fileName, *outFile, *inFile;&lt;br /&gt;
&lt;br /&gt;
	// Short-named options&lt;br /&gt;
	const char *shortOptions = &amp;quot;o:i:h&amp;quot;;&lt;br /&gt;
	// Long-named options&lt;br /&gt;
	static struct option longOptions[] =&lt;br /&gt;
	{&lt;br /&gt;
		{&amp;quot;in&amp;quot;,		required_argument, 0,  'i' },&lt;br /&gt;
		{&amp;quot;out&amp;quot;,		required_argument, 0,  'o' },&lt;br /&gt;
		{&amp;quot;help&amp;quot;,	no_argument, 	   0,  'h' },&lt;br /&gt;
		{0,         0,                 0,   0  }&lt;br /&gt;
	};&lt;br /&gt;
&lt;br /&gt;
	result = True;&lt;br /&gt;
	outFile = inFile = NULL;&lt;br /&gt;
&lt;br /&gt;
	// Disable default error message&lt;br /&gt;
	opterr = 0;&lt;br /&gt;
&lt;br /&gt;
	// Parse options&lt;br /&gt;
	result = getopt_long(argc, argv, shortOptions, longOptions, NULL);&lt;br /&gt;
	if (result &amp;lt; 0)&lt;br /&gt;
		printAndDie(&amp;quot;Wrong input. Run 'redir -h' for help.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	j = 1;&lt;br /&gt;
	while (result != -1 &amp;amp;&amp;amp; result != '?')&lt;br /&gt;
	{&lt;br /&gt;
		// Get the option value&lt;br /&gt;
		switch (result)&lt;br /&gt;
		{&lt;br /&gt;
		case 'i':&lt;br /&gt;
			inFile = optarg;&lt;br /&gt;
			j = optind;&lt;br /&gt;
			break;&lt;br /&gt;
		case 'o':&lt;br /&gt;
			outFile = optarg;&lt;br /&gt;
			j = optind;&lt;br /&gt;
			break;&lt;br /&gt;
		case 'h':&lt;br /&gt;
			printf(&amp;quot;Usage: [options] command\n&amp;quot;);&lt;br /&gt;
			printf(&amp;quot; options:\n&amp;quot;);&lt;br /&gt;
			printf(&amp;quot;  -i --in    required_argument   Redirect input.\n&amp;quot;);&lt;br /&gt;
			printf(&amp;quot;  -o --out   required_argument   Redirect output.\n&amp;quot;);&lt;br /&gt;
			printf(&amp;quot;  -h --help  no_argument         Show this help.\n&amp;quot;);&lt;br /&gt;
			exit(EXIT_SUCCESS);&lt;br /&gt;
		}&lt;br /&gt;
		result = getopt_long(argc, argv, shortOptions, longOptions, NULL);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Parse command&lt;br /&gt;
	command = (char **) malloc((argc - optind + 1) * sizeof (char *));&lt;br /&gt;
	fileName = argv[j];&lt;br /&gt;
	i = 0;&lt;br /&gt;
	while (j &amp;lt; argc)&lt;br /&gt;
		command[i++] = argv[j++];&lt;br /&gt;
	command[i] = NULL;&lt;br /&gt;
&lt;br /&gt;
	redirectAndRun(outFile, inFile, fileName, command);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Re-direct [input, output] and run a command&lt;br /&gt;
 * Input: outFile, output file&lt;br /&gt;
 *        inFile,  input file&lt;br /&gt;
 *        command, command&lt;br /&gt;
 *        args,    command arguments&lt;br /&gt;
 */&lt;br /&gt;
static void redirectAndRun(char *outFile, char *inFile, char *command, char *args[])&lt;br /&gt;
{&lt;br /&gt;
	int pid, outFD, inFD;&lt;br /&gt;
&lt;br /&gt;
	outFD = inFD = 0;&lt;br /&gt;
	if (inFile)&lt;br /&gt;
	{&lt;br /&gt;
		inFD = open(inFile, O_RDONLY);&lt;br /&gt;
		if (inFD &amp;lt; 0)&lt;br /&gt;
			errorAndDie(&amp;quot;open&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
	if (outFile)&lt;br /&gt;
	{&lt;br /&gt;
		outFD = open(outFile, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IRGRP | S_IWGRP | S_IWUSR);&lt;br /&gt;
		if (outFD &amp;lt; 0)&lt;br /&gt;
			errorAndDie(&amp;quot;open&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	if ((pid = fork()) &amp;lt; 0)&lt;br /&gt;
		errorAndDie(&amp;quot;fork&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	// Child process&lt;br /&gt;
	if (pid == 0)&lt;br /&gt;
	{&lt;br /&gt;
		if (inFile)&lt;br /&gt;
		{&lt;br /&gt;
			if (dup2(inFD, STDIN_FILENO) &amp;lt; 0)&lt;br /&gt;
				errorAndDie(&amp;quot;dup2&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
			if (close(inFD) &amp;lt; 0)&lt;br /&gt;
				 errorAndDie(&amp;quot;close&amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
		if (outFile)&lt;br /&gt;
		{&lt;br /&gt;
			if (dup2(outFD, STDOUT_FILENO) &amp;lt; 0)&lt;br /&gt;
				errorAndDie(&amp;quot;dup2&amp;quot;);&lt;br /&gt;
			if (close(outFD) &amp;lt; 0)&lt;br /&gt;
				 errorAndDie(&amp;quot;close&amp;quot;);&lt;br /&gt;
		}&lt;br /&gt;
	    execvp(command, args);&lt;br /&gt;
	    errorAndDie(&amp;quot;execvp&amp;quot;);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	// Parent process&lt;br /&gt;
	if (inFile)&lt;br /&gt;
		if (close(inFD) &amp;lt; 0)&lt;br /&gt;
			 errorAndDie(&amp;quot;close&amp;quot;);&lt;br /&gt;
	if (outFile)&lt;br /&gt;
		if (close(outFD) &amp;lt; 0)&lt;br /&gt;
			 errorAndDie(&amp;quot;close&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Print error message and exit&lt;br /&gt;
 * Input: msg, the error message&lt;br /&gt;
 */&lt;br /&gt;
static inline void errorAndDie(const char *msg)&lt;br /&gt;
{&lt;br /&gt;
	perror(msg);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Print message and exit&lt;br /&gt;
 * Input: msg, the message&lt;br /&gt;
 */&lt;br /&gt;
static inline void printAndDie(const char *msg)&lt;br /&gt;
{&lt;br /&gt;
	printf(&amp;quot;%s\n&amp;quot;, msg);&lt;br /&gt;
	exit(EXIT_FAILURE);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=Esercizio 3=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
def ssend2(m, d1, d2):&lt;br /&gt;
	msg = ( SND, getpid(), d1, d2, m )&lt;br /&gt;
	asend(msg, server)&lt;br /&gt;
	return arecv(server)&lt;br /&gt;
&lt;br /&gt;
def sreceive():&lt;br /&gt;
	msg = ( RCV, getpid(), None, None, None )&lt;br /&gt;
	asend(msg, server)&lt;br /&gt;
	return arecv(server)&lt;br /&gt;
&lt;br /&gt;
def server():&lt;br /&gt;
	while True:&lt;br /&gt;
		flag, src, d1, d2, msg = arecv(*)&lt;br /&gt;
		if flag == RCV:&lt;br /&gt;
			msg, sender, _, _ = dbSnd.retrieve(query = '(?, ?, src, ?) or (?, ?, ?, src)')&lt;br /&gt;
			if msg:&lt;br /&gt;
				asend(msg, src)&lt;br /&gt;
				asend(src, sender)&lt;br /&gt;
			else:&lt;br /&gt;
				dbRcv.insert(src)&lt;br /&gt;
		else:&lt;br /&gt;
			if dbRcv.retrieve(d1):&lt;br /&gt;
				asend(msg, d1)&lt;br /&gt;
				asend(d1, src)&lt;br /&gt;
			elif dbRcv.retrieve(d2):&lt;br /&gt;
				asend(msg, d2)&lt;br /&gt;
				asend(d2, src)&lt;br /&gt;
			else:&lt;br /&gt;
				dbSnd.insert((msg, src, d1, d2))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
==Esercizio 3==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
import os, sys&lt;br /&gt;
&lt;br /&gt;
'''&lt;br /&gt;
@summary: Walk through a directory tree.&lt;br /&gt;
          Populate a dictionary with key-value pair &lt;br /&gt;
          { file name - (last modification - directory) }.&lt;br /&gt;
          Create soft links of the last modified files in a destination directory.&lt;br /&gt;
@param sources:     list of source directories  &lt;br /&gt;
@param n:           number of source directories&lt;br /&gt;
@param destination: the destination directory&lt;br /&gt;
'''&lt;br /&gt;
def MergeDirectories(sources, n, destination):&lt;br /&gt;
    # Populate the dictionary&lt;br /&gt;
    fileLastMod = {}&lt;br /&gt;
    &lt;br /&gt;
    for i in range(0, n):&lt;br /&gt;
        for fileName in os.listdir(sources[i]):&lt;br /&gt;
            filePath = os.path.join(sources[i], fileName)&lt;br /&gt;
            lastMod = os.path.getmtime(filePath)&lt;br /&gt;
            if fileLastMod.get(fileName, None) == None:&lt;br /&gt;
                fileLastMod[fileName] = (lastMod, sources[i])&lt;br /&gt;
            elif fileLastMod[fileName][0] &amp;lt; lastMod:&lt;br /&gt;
                fileLastMod[fileName] = (lastMod, sources[i])&lt;br /&gt;
           &lt;br /&gt;
    # Generate the soft links&lt;br /&gt;
    for key, value in fileLastMod.items():&lt;br /&gt;
        srcPath = os.path.join(value[1], key)&lt;br /&gt;
        dstPath = os.path.join(destination, key)&lt;br /&gt;
        if not os.path.lexists(dstPath):&lt;br /&gt;
            os.symlink(srcPath, dstPath)&lt;br /&gt;
&lt;br /&gt;
# Entry point&lt;br /&gt;
def Main(argv, argc):&lt;br /&gt;
    &lt;br /&gt;
    # Perform a sanity check and parse the parameters&lt;br /&gt;
    if argc &amp;lt; 4:&lt;br /&gt;
        sys.exit(&amp;quot;The function requires at least three parameters to be passed in.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    last = argc - 1&lt;br /&gt;
    source = []&lt;br /&gt;
    for i in range(1, last):      &lt;br /&gt;
        if not os.path.isabs(argv[i]):&lt;br /&gt;
            source.append(os.path.abspath(argv[i]))&lt;br /&gt;
        else:&lt;br /&gt;
            source.append(argv[i])&lt;br /&gt;
            &lt;br /&gt;
        if not os.path.isdir(source[i - 1]):&lt;br /&gt;
            sys.exit(&amp;quot;The parameters should be existing directories.&amp;quot;) &lt;br /&gt;
            &lt;br /&gt;
    destination = argv[last]     &lt;br /&gt;
   &lt;br /&gt;
    MergeDirectories(source, last - 1, destination)&lt;br /&gt;
            &lt;br /&gt;
    print(&amp;quot;Done!&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
    sys.exit(Main(sys.argv, len(sys.argv)))&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>TomOgn</name></author>
	</entry>
</feed>