<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://so.v2.cs.unibo.it/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stanislao</id>
	<title>Sistemi Operativi - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://so.v2.cs.unibo.it/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stanislao"/>
	<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php/Special:Contributions/Stanislao"/>
	<updated>2026-04-30T03:22:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=718</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=718"/>
		<updated>2014-05-13T14:31:46Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio c.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
monitor dualwriter{&lt;br /&gt;
	queue buffer1;&lt;br /&gt;
	queue buffer2;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread1;&lt;br /&gt;
	condition oktoread2;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry void write(type1 e1, type2 e2){&lt;br /&gt;
		if((buffer1.len() == BUFSIZE) || (buffer2.len() == BUFSIZE)) /*se uno dei due buffer è pieno non puoi inserire*/&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.enqueue(e1);&lt;br /&gt;
		buffer2.enqueue(e2);&lt;br /&gt;
		&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1(){&lt;br /&gt;
		if(buffer1.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2(){&lt;br /&gt;
		if(buffer2.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer2.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Giulia&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// bar (z,t) &amp;lt;z= z xor t, t= t xor z, z = z xor t&amp;gt;&lt;br /&gt;
&lt;br /&gt;
z   t   z   t   z&lt;br /&gt;
0   0   0   0   0&lt;br /&gt;
0   1   1   0   1&lt;br /&gt;
1   0   1   1   0&lt;br /&gt;
1   1   0   1   1&lt;br /&gt;
&lt;br /&gt;
void Swap(bool z, bool t){&lt;br /&gt;
      bool tmp;&lt;br /&gt;
         z=t;&lt;br /&gt;
         t=tmp;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=717</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=717"/>
		<updated>2014-05-13T14:30:58Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio c.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
monitor dualwriter{&lt;br /&gt;
	queue buffer1;&lt;br /&gt;
	queue buffer2;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread1;&lt;br /&gt;
	condition oktoread2;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry void write(type1 e1, type2 e2){&lt;br /&gt;
		if((buffer1.len() == BUFSIZE) || (buffer2.len() == BUFSIZE)) /*se uno dei due buffer è pieno non puoi inserire*/&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.enqueue(e1);&lt;br /&gt;
		buffer2.enqueue(e2);&lt;br /&gt;
		&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1(){&lt;br /&gt;
		if(buffer1.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2(){&lt;br /&gt;
		if(buffer2.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer2.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Giulia&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// bar (z,t) &amp;lt;z= z xor t, t= t xor z, z = z xor t&amp;gt;&lt;br /&gt;
&lt;br /&gt;
z   t   z   t   z&lt;br /&gt;
0   0   0   0  0&lt;br /&gt;
0   1   1   0  1&lt;br /&gt;
1   0   1   1  0&lt;br /&gt;
1   1   0   1  1&lt;br /&gt;
&lt;br /&gt;
void Swap(boolean z, boolean t){&lt;br /&gt;
      boolean tmp;&lt;br /&gt;
         z=t;&lt;br /&gt;
         t=tmp;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=716</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=716"/>
		<updated>2014-05-13T14:30:18Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio c.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
monitor dualwriter{&lt;br /&gt;
	queue buffer1;&lt;br /&gt;
	queue buffer2;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread1;&lt;br /&gt;
	condition oktoread2;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry void write(type1 e1, type2 e2){&lt;br /&gt;
		if((buffer1.len() == BUFSIZE) || (buffer2.len() == BUFSIZE)) /*se uno dei due buffer è pieno non puoi inserire*/&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.enqueue(e1);&lt;br /&gt;
		buffer2.enqueue(e2);&lt;br /&gt;
		&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1(){&lt;br /&gt;
		if(buffer1.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2(){&lt;br /&gt;
		if(buffer2.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer2.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Giulia&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// bar (z,t) &amp;lt;z= z xor t, t= t xor z, z = z xor t&amp;gt;&lt;br /&gt;
&lt;br /&gt;
z   t   z   t   z&lt;br /&gt;
0   0  0   0  0&lt;br /&gt;
0   1  1   0  1&lt;br /&gt;
1   0  1   1  0&lt;br /&gt;
1   1  0   1  1&lt;br /&gt;
&lt;br /&gt;
void Swap(boolean z, boolean t){&lt;br /&gt;
      boolean tmp;&lt;br /&gt;
         z=t;&lt;br /&gt;
         t=tmp;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=715</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=715"/>
		<updated>2014-05-13T14:23:56Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio c.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
monitor dualwriter{&lt;br /&gt;
	queue buffer1;&lt;br /&gt;
	queue buffer2;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread1;&lt;br /&gt;
	condition oktoread2;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry void write(type1 e1, type2 e2){&lt;br /&gt;
		if((buffer1.len() == BUFSIZE) || (buffer2.len() == BUFSIZE)) /*se uno dei due buffer è pieno non puoi inserire*/&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.enqueue(e1);&lt;br /&gt;
		buffer2.enqueue(e2);&lt;br /&gt;
		&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1(){&lt;br /&gt;
		if(buffer1.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2(){&lt;br /&gt;
		if(buffer2.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer2.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Giulia&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=714</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=714"/>
		<updated>2014-05-13T14:22:57Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=713</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=713"/>
		<updated>2014-05-13T14:22:21Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio c.1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
monitor dualwriter{&lt;br /&gt;
	queue buffer1;&lt;br /&gt;
	queue buffer2;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread1;&lt;br /&gt;
	condition oktoread2;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry void write(type1 e1, type2 e2){&lt;br /&gt;
		if((buffer1.len() == BUFSIZE) || (buffer2.len() == BUFSIZE)) /*se uno dei due buffer è pieno non puoi inserire*/&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.enqueue(e1);&lt;br /&gt;
		buffer2.enqueue(e2);&lt;br /&gt;
		&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1(){&lt;br /&gt;
		if(buffer1.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer1.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2(){&lt;br /&gt;
		if(buffer2.len() == 0) /*buffer vuoto*/&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		&lt;br /&gt;
		buffer2.dequeue;&lt;br /&gt;
		oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Giulia&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=711</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=711"/>
		<updated>2014-05-12T15:09:58Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;PUNTO A:&amp;lt;/b&amp;gt; (7+256+(256^2)+(256^3))*1kb =16.843.015kb quindi approssimativamente 16MB&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt; PUNTO B:&amp;lt;/B&amp;gt; blocco indiretto triplo -&amp;gt; primo livello di idirizzamento 256 esimo blocco -&amp;gt; secondo livello di indirizzamento 256 esimo blocco -&amp;gt; terzo livello di indirizzamento al blocco 100000. Qundi in totale 4 blocchi &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:Holt.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=709</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=709"/>
		<updated>2014-05-12T13:39:05Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso &lt;br /&gt;
(se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi &lt;br /&gt;
non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;PUNTO A:&amp;lt;/b&amp;gt; (7+256+(256^2)+(256^3))*1kb =16.843.015kb quindi approssimativamente 16MB&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt; PUNTO B:&amp;lt;/B&amp;gt; blocco indiretto triplo -&amp;gt; primo livello di idirizzamento 256 esimo blocco -&amp;gt; secondo livello di indirizzamento 256 esimo blocco -&amp;gt; terzo livello di indirizzamento al blocco 100000. Qundi in totale 4 blocchi &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:Holt.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=704</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=704"/>
		<updated>2014-05-09T15:14:22Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt; [http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo Compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
// funziona anche in caso di overflow&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=703</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=703"/>
		<updated>2014-05-09T15:14:07Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt; [http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo Compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
&lt;br /&gt;
funziona anche in caso di overflow&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=702</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=702"/>
		<updated>2014-05-09T15:10:44Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt; [http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo Compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=701</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=701"/>
		<updated>2014-05-09T15:00:35Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// foo(x,y) &amp;lt;x=2+y , y=2+x&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int g = 0;&lt;br /&gt;
&lt;br /&gt;
csenter:&lt;br /&gt;
&lt;br /&gt;
          do&lt;br /&gt;
               int l;&lt;br /&gt;
               foo(l, g);&lt;br /&gt;
          while(l!=2)&lt;br /&gt;
&lt;br /&gt;
csexit:&lt;br /&gt;
&lt;br /&gt;
g = 0;&lt;br /&gt;
        &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=700</id>
		<title>ProvaTeorica 2013.02.14</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.14&amp;diff=700"/>
		<updated>2014-05-09T14:55:07Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Created page with &amp;quot;&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=699</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=699"/>
		<updated>2014-05-09T14:54:26Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Questo &amp;amp;egrave; il Wiki del Corso di Sistemi Operativi&lt;br /&gt;
&lt;br /&gt;
[[Esercizi a caso del Prof.]]&lt;br /&gt;
&lt;br /&gt;
[[Decalogo di Programmazione Concorrente]]&lt;br /&gt;
&lt;br /&gt;
[[Python Programma tieni punteggio.]]&lt;br /&gt;
&lt;br /&gt;
[[Comandi visti alle lezioni.]]&lt;br /&gt;
&lt;br /&gt;
[[SYS CALL viste a lezione.]]&lt;br /&gt;
&lt;br /&gt;
[[Parametri con getopt().]]&lt;br /&gt;
&lt;br /&gt;
[[Funzione con numero variabile di parametri.]]&lt;br /&gt;
&lt;br /&gt;
[[stampf - implementazione ridotta della printf.]]&lt;br /&gt;
&lt;br /&gt;
[[Producer&amp;amp;Consumer MP.]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2014.01.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.09.13]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.07.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.05.29]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.01.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.09.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2005.02.10]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2011.07.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.02.09]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.05.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.06.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2011.02.11]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.01.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2014.01.22]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2012.07.16]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica_2010.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.01.16]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2009.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.09.17]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.09.07]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.02.03]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.02.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.01.15]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2011.01.17]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2010.05.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2012.01.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.09.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.06.20]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.05.30]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2009.01.30]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2012.01.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.06.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.02.14]]&lt;br /&gt;
----&lt;br /&gt;
Ricordate che per creare un account o quando viene richiesto di risolvere un semplice calcolo occorre ricordare quanto scritto [[qui]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=677</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=677"/>
		<updated>2014-05-04T15:38:10Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso &lt;br /&gt;
(se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi &lt;br /&gt;
non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale &lt;br /&gt;
(cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	       generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
sono q	       sono p&lt;br /&gt;
sono p	       sono q&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi &lt;br /&gt;
i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;PUNTO A:&amp;lt;/b&amp;gt; (7+256+(256^2)+(256^3))*1kb =16.843.015kb quindi approssimativamente 16MB&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt; PUNTO B:&amp;lt;/B&amp;gt; blocco indiretto triplo -&amp;gt; primo livello di idirizzamento 256 esimo blocco -&amp;gt; secondo livello di indirizzamento 256 esimo blocco -&amp;gt; terzo livello di indirizzamento al blocco 100000. Qundi in totale 4 blocchi &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:Holt.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:Holt.png&amp;diff=674</id>
		<title>File:Holt.png</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:Holt.png&amp;diff=674"/>
		<updated>2014-05-04T13:58:30Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=673</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=673"/>
		<updated>2014-05-04T13:58:04Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso &lt;br /&gt;
(se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi &lt;br /&gt;
non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale &lt;br /&gt;
(cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	       generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
sono q	       sono p&lt;br /&gt;
sono p	       sono q&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi &lt;br /&gt;
i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;PUNTO A:&amp;lt;/b&amp;gt; (7+256+(256^2)+(256^3))*1kb =16.843.015kb quindi approssimativamente 16MB&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt; PUNTO B:&amp;lt;/B&amp;gt; blocco indiretto triplo -&amp;gt; primo livello di idirizzamento 256 esimo blocco -&amp;gt; secondo livello di indirizzamento 256 esimo blocco -&amp;gt; terzo livello di indirizzamento al blocco 100000. Qundi in totale 4 blocchi &amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[[File:Holt.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=672</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=672"/>
		<updated>2014-05-03T17:12:00Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso &lt;br /&gt;
(se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi &lt;br /&gt;
non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale &lt;br /&gt;
(cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	       generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
sono q	       sono p&lt;br /&gt;
sono p	       sono q&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi &lt;br /&gt;
i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt;PUNTO A:&amp;lt;/b&amp;gt; (7+256+(256^2)+(256^3))*1kb =16.843.015kb quindi approssimativamente 16MB&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt; &amp;lt;b&amp;gt; PUNTO B:&amp;lt;/B&amp;gt; blocco indiretto triplo -&amp;gt; primo livello di idirizzamento 256 esimo blocco -&amp;gt; secondo livello di indirizzamento 256 esimo blocco -&amp;gt; terzo livello di indirizzamento al blocco 100000. Qundi in totale 4 blocchi &amp;lt;/p&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=671</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=671"/>
		<updated>2014-05-02T16:09:12Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso &lt;br /&gt;
(se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi &lt;br /&gt;
non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale &lt;br /&gt;
(cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	       generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
sono q	       sono p&lt;br /&gt;
sono p	       sono q&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi &lt;br /&gt;
i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=670</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=670"/>
		<updated>2014-05-02T16:05:04Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale &lt;br /&gt;
(cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	       generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono p	       sono p&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
sono q	       sono p&lt;br /&gt;
sono p	       sono q&lt;br /&gt;
sono q	       sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi &lt;br /&gt;
i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali */&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=669</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=669"/>
		<updated>2014-05-02T16:03:18Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio c.2 &amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p hanno come invariante 2*np &amp;lt;= nv + Init, dove np e' il numero di operazioni P completate, &lt;br /&gt;
nv e' il numero delle operazioni V completate e Init e' il valore iniziale (cioe' occorrono 2 operazioni V per sbloccare un processo che ha fatto P).&lt;br /&gt;
I semafori v2p hanno lo stesso potere espressivo dei semafori generali o no?&lt;br /&gt;
Produrre una dimostrazione della tesi sostenuta.*/&lt;br /&gt;
&lt;br /&gt;
/* I semafori v2p non hanno lo stesso potere espressivo di quelli generali&lt;br /&gt;
&lt;br /&gt;
DIMOSTRAZIONE: prendo due processi P e Q in questo modo qui: */&lt;br /&gt;
&lt;br /&gt;
process P{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		P(); &lt;br /&gt;
&lt;br /&gt;
		printf(“sono p”);&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
process Q{&lt;br /&gt;
&lt;br /&gt;
	while (true){&lt;br /&gt;
&lt;br /&gt;
		printf(“sono q”);&lt;br /&gt;
		&lt;br /&gt;
		V();&lt;br /&gt;
&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* inizializzo entrambi i semafori a 2 */&lt;br /&gt;
&lt;br /&gt;
semaforo v2p(2) &lt;br /&gt;
semaforo generale(2)&lt;br /&gt;
&lt;br /&gt;
 PPPQQQ // sequenza di avvicendamento dei processi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
v2p(2)	generale(2)  // v2p VS generale&lt;br /&gt;
&lt;br /&gt;
sono p	sono p&lt;br /&gt;
sono p	sono p&lt;br /&gt;
sono q	sono q&lt;br /&gt;
sono q	sono p&lt;br /&gt;
sono p	sono q&lt;br /&gt;
sono q	sono q&lt;br /&gt;
&lt;br /&gt;
/* con la stessa sequenza di avvicendamento dei processi possiamo notare che l'output generato da entrambi i processi è diverso e quindi i semafori v2p non hanno lo stesso potere espressivo dei semafori generali&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=668</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=668"/>
		<updated>2014-05-02T14:58:19Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.05.30.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=667</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=667"/>
		<updated>2014-05-02T14:54:10Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, &lt;br /&gt;
sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) &lt;br /&gt;
somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. &lt;br /&gt;
In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
unsigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
		unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=666</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=666"/>
		<updated>2014-05-02T14:53:13Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=665</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=665"/>
		<updated>2014-05-02T14:52:45Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=664</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=664"/>
		<updated>2014-05-02T14:52:32Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=663</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=663"/>
		<updated>2014-05-02T14:52:05Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=662</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=662"/>
		<updated>2014-05-02T14:51:39Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/&amp;lt;h2&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=661</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=661"/>
		<updated>2014-05-02T14:49:14Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;Esercizio c.1&amp;lt;/&amp;lt;h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Esercizio c.1: scrivere un monitor eventp che realizzi un servizio di sincronizzazione cosi' definito:&lt;br /&gt;
procedure entry EP *create(unsigned value): crea un nuovo descrittore. Ogni descrittore ha un contatore associato.&lt;br /&gt;
&lt;br /&gt;
Value e' il valore iniziale del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value): se il contatore ha un valore tale che se si sommasse value causerebbe overflow, sospende il processo chiamante. In ogni caso (se la somma e' possibile senza overflow o quando la somma e' possibile senza overflow) somma value al valore del contatore.&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read(EP *d): se il contatore ha valore nullo sospende il processo chiamante fino a che il contatore diventi non nullo. In ogni caso restituisce il valore del contatore e riporta il contatore al valore zero.&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP *d): termina le operazioni del descrittore d e cancella il descrittore.&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor eventp{&lt;br /&gt;
&lt;br /&gt;
#define OVERFLOW 999;&lt;br /&gt;
&lt;br /&gt;
condition okToWrite, okToRead;&lt;br /&gt;
usigned int oldValue;&lt;br /&gt;
&lt;br /&gt;
struct EP { &lt;br /&gt;
			unsigned int count; &lt;br /&gt;
} d;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry EP *create(value){&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
d.count = value;&lt;br /&gt;
&lt;br /&gt;
return d; &lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
procedure entry void write(EP *d, unsigned value){&lt;br /&gt;
&lt;br /&gt;
	if(d.count+value &amp;gt; OVERFLOW)&lt;br /&gt;
			&lt;br /&gt;
			okToWrite.wait();&lt;br /&gt;
			d.count= d.count + value;&lt;br /&gt;
			okToRead.signal();&lt;br /&gt;
	else&lt;br /&gt;
			d.count = d.count + value;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
		&lt;br /&gt;
&lt;br /&gt;
procedure entry unsigned read (EP *d){&lt;br /&gt;
&lt;br /&gt;
		if(d.count == NULL)&lt;br /&gt;
				&lt;br /&gt;
			okToRead.wait();&lt;br /&gt;
			oldValue = d.count;&lt;br /&gt;
			d.count = 0;&lt;br /&gt;
			okToWrite.signal();&lt;br /&gt;
			return oldValue;&lt;br /&gt;
		else&lt;br /&gt;
			oldValue=d.count;&lt;br /&gt;
			d.count=0;&lt;br /&gt;
			return oldValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry void close(EP* d){&lt;br /&gt;
&lt;br /&gt;
			close(d);&lt;br /&gt;
			delete(d);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=660</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=660"/>
		<updated>2014-05-02T14:47:41Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Questo &amp;amp;egrave; il Wiki del Corso di Sistemi Operativi&lt;br /&gt;
&lt;br /&gt;
[[Esercizi a caso del Prof.]]&lt;br /&gt;
&lt;br /&gt;
[[Decalogo di Programmazione Concorrente]]&lt;br /&gt;
&lt;br /&gt;
[[Python Programma tieni punteggio.]]&lt;br /&gt;
&lt;br /&gt;
[[Comandi visti alle lezioni.]]&lt;br /&gt;
&lt;br /&gt;
[[SYS CALL viste a lezione.]]&lt;br /&gt;
&lt;br /&gt;
[[Parametri con getopt().]]&lt;br /&gt;
&lt;br /&gt;
[[Funzione con numero variabile di parametri.]]&lt;br /&gt;
&lt;br /&gt;
[[stampf - implementazione ridotta della printf.]]&lt;br /&gt;
&lt;br /&gt;
[[Producer&amp;amp;Consumer MP.]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2014.01.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.09.13]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.07.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.05.29]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.01.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.09.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2005.02.10]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2011.07.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.02.09]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.05.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.06.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2011.02.11]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.01.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2014.01.22]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2012.07.16]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica_2010.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.01.16]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2009.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.09.17]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.09.07]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.02.03]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.02.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.01.15]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2011.01.17]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2010.05.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2012.01.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.09.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.06.20]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.05.30]]&lt;br /&gt;
----&lt;br /&gt;
Ricordate che per creare un account o quando viene richiesto di risolvere un semplice calcolo occorre ricordare quanto scritto [[qui]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:RoundRobin2cpu.png&amp;diff=659</id>
		<title>File:RoundRobin2cpu.png</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:RoundRobin2cpu.png&amp;diff=659"/>
		<updated>2014-05-02T13:30:57Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=658</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=658"/>
		<updated>2014-05-02T13:30:40Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:RoundRobin2cpu.png]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:DoppiaCpu.png&amp;diff=657</id>
		<title>File:DoppiaCpu.png</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:DoppiaCpu.png&amp;diff=657"/>
		<updated>2014-05-02T13:24:16Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2014.01.22&amp;diff=656</id>
		<title>ProvaTeorica 2014.01.22</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2014.01.22&amp;diff=656"/>
		<updated>2014-05-02T13:00:10Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: /* Esercizio g.1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
URL: http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf&lt;br /&gt;
&lt;br /&gt;
@author: Alessandro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor bridge {&lt;br /&gt;
condition oktomove;	/* auto attraversa il ponte */&lt;br /&gt;
int turn=0;		/*indica il senso delle auto */&lt;br /&gt;
int est=0,ovest=0;      /*contatori delle auto da est e da ovest */&lt;br /&gt;
Queue q;		/*coda delle senso delle macchine in attesa */&lt;br /&gt;
&lt;br /&gt;
procedure entry enter (char EoW)&lt;br /&gt;
{&lt;br /&gt;
	if(EoW == &amp;quot;E&amp;quot;)		/* viene da est */&lt;br /&gt;
	{&lt;br /&gt;
		if(turn == 2 || est &amp;gt;=N || !empty(q))  &lt;br /&gt;
		{&lt;br /&gt;
			q=enqueue(&amp;quot;E&amp;quot;);		/*inserisco nella coda dei sensi*/	&lt;br /&gt;
			oktomove.wait();   	/*aspetta*/&lt;br /&gt;
									&lt;br /&gt;
		}&lt;br /&gt;
	turn = 1;	/*impongo il senso delle auto in circolo nel ponte */&lt;br /&gt;
	est++;&lt;br /&gt;
	}&lt;br /&gt;
	else		/* viene da ovest */&lt;br /&gt;
	{&lt;br /&gt;
		if(turn ==1 || ovest &amp;gt;=N || !empty(q))&lt;br /&gt;
		{&lt;br /&gt;
		        q=enqueue(&amp;quot;O&amp;quot;);		/*inserisco nella coda dei sensi*/&lt;br /&gt;
			oktomove.wait();	/*aspetta*/&lt;br /&gt;
									&lt;br /&gt;
		}&lt;br /&gt;
	turn = 2;	/*impongo il senso delle auto in circolo nel ponte */&lt;br /&gt;
	ovest++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry exit(char EoW)&lt;br /&gt;
{&lt;br /&gt;
	char r;&lt;br /&gt;
	if(EoW == &amp;quot;O&amp;quot;)&lt;br /&gt;
	{&lt;br /&gt;
	est--;&lt;br /&gt;
	r=head(q);                          /* leggo la prossima auto che aspetta di entrare */&lt;br /&gt;
		if(est == 0 || r == &amp;quot;E&amp;quot;)     /*nessuna auto in transito nel ponte o il prossimo va nella stessa direzione*/&lt;br /&gt;
		{&lt;br /&gt;
		est--;&lt;br /&gt;
			if(est == 0)	/*nessuna auto in transito nel ponte */&lt;br /&gt;
			{&lt;br /&gt;
			turn = 0;	/*avanti un altro */&lt;br /&gt;
			}&lt;br /&gt;
			if(!empty(q))&lt;br /&gt;
			{&lt;br /&gt;
			q.dequeue();&lt;br /&gt;
			oktomove.signal();	/*segnale*/&lt;br /&gt;
			}&lt;br /&gt;
                }&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
	ovest--;&lt;br /&gt;
	r=head(q);                          /* leggo la prossima auto che aspetta di entrare */&lt;br /&gt;
		if(ovest == 0 || r == &amp;quot;O&amp;quot;)	 /*nessuna auto in transito nel ponte o il prossimo va nella stessa direzione*/&lt;br /&gt;
		{&lt;br /&gt;
		turn = 0;	/*avanti un altro */&lt;br /&gt;
		}&lt;br /&gt;
		if(!empty(q))&lt;br /&gt;
		{&lt;br /&gt;
		q.dequeue();		&lt;br /&gt;
		oktomove.signal();	/*segnale*/&lt;br /&gt;
	        }&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * URL: http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf&lt;br /&gt;
 * author: Tommaso Ognibene&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
monitor bridge&lt;br /&gt;
{&lt;br /&gt;
	condition okE;    // attraversare in direzione Est&lt;br /&gt;
	condition okW;    // attraversare in direzione Ovest&lt;br /&gt;
	int n = 0;        // numero di veicoli sul ponte&lt;br /&gt;
	int waitingE = 0; // numero di veicoli che attendono di attraversare in direzione Est&lt;br /&gt;
	int waitingW = 0; // numero di veicoli che attendono di attraversare in direzione Ovest&lt;br /&gt;
	bool toE = true;  // direzione di attraversamento&lt;br /&gt;
&lt;br /&gt;
	procedure entry enter(Vehicle vehicle)&lt;br /&gt;
	{&lt;br /&gt;
		// [Case 1] Il veicolo vuole attraversare in direzione Ovest&lt;br /&gt;
		if (vehicle.To == 'W')&lt;br /&gt;
		{&lt;br /&gt;
			/* Se - il numero di veicoli sul ponte ha raggiunto il massimo; oppure&lt;br /&gt;
			      - qualcuno sta attraversando in direzione opposta; oppure&lt;br /&gt;
			      - qualcuno sta attendendo di attraversare in direzione opposta */&lt;br /&gt;
			if (n == N || (toE &amp;amp;&amp;amp; n &amp;gt; 0) || (!toE &amp;amp;&amp;amp; waitingE &amp;gt; 0))&lt;br /&gt;
			{&lt;br /&gt;
				// Mi fermo e attendo di essere sbloccato&lt;br /&gt;
				waitingW++;&lt;br /&gt;
				okW.wait();&lt;br /&gt;
				waitingW--;&lt;br /&gt;
			}&lt;br /&gt;
			toE = false;&lt;br /&gt;
			n++;&lt;br /&gt;
			&lt;br /&gt;
			/* Se possibile, sblocco eventuali altri veicoli in attesa per la stessa direzione.&lt;br /&gt;
			 * Questo non crea starvation in quanto sono sicuramente un numero limitato. */&lt;br /&gt;
			if (n &amp;lt; N &amp;amp;&amp;amp; waitingE == 0)&lt;br /&gt;
				okW.signal();&lt;br /&gt;
		}&lt;br /&gt;
		// [Case 2] Il veicolo vuole attraversare in direzione Est&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			/* Se - il numero di veicoli sul ponte ha raggiunto il massimo; oppure&lt;br /&gt;
			      - qualcuno sta attraversando in direzione opposta; oppure&lt;br /&gt;
			      - qualcuno sta attendendo di attraversare in direzione opposta */&lt;br /&gt;
			if (n == N || (!toE &amp;amp;&amp;amp; n &amp;gt; 0) || (toE &amp;amp;&amp;amp; waitingW &amp;gt; 0))&lt;br /&gt;
			{&lt;br /&gt;
			        // Mi fermo e attendo di essere sbloccato&lt;br /&gt;
				waitingE++;&lt;br /&gt;
				okE.wait();&lt;br /&gt;
				waitingE--;&lt;br /&gt;
			}&lt;br /&gt;
			toE = true;&lt;br /&gt;
			n++;&lt;br /&gt;
&lt;br /&gt;
			/* Se possibile, sblocco eventuali altri veicoli in attesa per la stessa direzione.&lt;br /&gt;
			 * Questo non crea starvation in quanto sono sicuramente un numero limitato. */&lt;br /&gt;
			if (n &amp;lt; N &amp;amp;&amp;amp; waitingW == 0)&lt;br /&gt;
				okE.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	procedure entry exit(Vehicle vehicle)&lt;br /&gt;
	{&lt;br /&gt;
		n--;&lt;br /&gt;
		/* Se nessuno sta attraversando il ponte */&lt;br /&gt;
		if (n == 0)&lt;br /&gt;
		{&lt;br /&gt;
			// [Case 1] L'ultimo ad attraversare andava in direzione Ovest&lt;br /&gt;
			if (vehicle.To == 'W')&lt;br /&gt;
			{&lt;br /&gt;
			   /* Se esiste, attivo il veicolo che per primo si era messo&lt;br /&gt;
			      in attesa per la direzione opposta */&lt;br /&gt;
			   if (waitingE &amp;gt; 0)&lt;br /&gt;
				okE.signal();&lt;br /&gt;
			   else&lt;br /&gt;
				okW.signal();&lt;br /&gt;
			}&lt;br /&gt;
			// [Case 2] L'ultimo ad attraversare andava in direzione Est&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
			   /* Se esiste, attivo il veicolo che per primo si era messo&lt;br /&gt;
		              in attesa per la direzione opposta */&lt;br /&gt;
			   if (waitingW &amp;gt; 0)&lt;br /&gt;
				okW.signal();&lt;br /&gt;
			   else&lt;br /&gt;
				okE.signal();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La Mia soluzione:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * author: Midolo&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
Monitor Ponte {&lt;br /&gt;
#define O 0&lt;br /&gt;
#define E 1&lt;br /&gt;
condition oktocross[2];&lt;br /&gt;
int countwaiting[2], crossing;&lt;br /&gt;
&lt;br /&gt;
	bridge.enter(dir){&lt;br /&gt;
		if(crossing != 0 || countwaiting[1-dir] != 0){&lt;br /&gt;
			countwaiting[dir]++;&lt;br /&gt;
			oktocross[dir].wait();&lt;br /&gt;
			countwaiting[dir]--;            &lt;br /&gt;
		}&lt;br /&gt;
		crossing++;&lt;br /&gt;
		if(crossing &amp;lt; N){ &lt;br /&gt;
			oktocross[dir].signal();&lt;br /&gt;
		}    &lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	bridge.exit(dir){&lt;br /&gt;
		crossing--;&lt;br /&gt;
		if(crossing == 0){&lt;br /&gt;
			if(countwaiting[dir] != 0){&lt;br /&gt;
				oktocross[dir].signal();&lt;br /&gt;
			}else{&lt;br /&gt;
				oktocross[1-dir].signal();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
        &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Esercizio g.1==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;Punto a&amp;quot;&lt;br /&gt;
                123456789123456789123456789...&lt;br /&gt;
                 &lt;br /&gt;
                111111111111111111111111111&lt;br /&gt;
                 22222222222222222222222222          MIN e MAXNUM (infiniti page fault)&lt;br /&gt;
                  3456789993456789993456789&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Punto b&amp;quot;&lt;br /&gt;
                123453453453453453453453453...&lt;br /&gt;
                 &lt;br /&gt;
                111111111111111111111111111&lt;br /&gt;
                 22222222222222222222222222          MIN e MAXNUM (page fault ad ogni accesso)&lt;br /&gt;
                  3453453453453453453453453&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2014.01.22&amp;diff=655</id>
		<title>ProvaTeorica 2014.01.22</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2014.01.22&amp;diff=655"/>
		<updated>2014-05-02T12:59:34Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: /* Esercizio g.1 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
URL: http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf&lt;br /&gt;
&lt;br /&gt;
@author: Alessandro&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
monitor bridge {&lt;br /&gt;
condition oktomove;	/* auto attraversa il ponte */&lt;br /&gt;
int turn=0;		/*indica il senso delle auto */&lt;br /&gt;
int est=0,ovest=0;      /*contatori delle auto da est e da ovest */&lt;br /&gt;
Queue q;		/*coda delle senso delle macchine in attesa */&lt;br /&gt;
&lt;br /&gt;
procedure entry enter (char EoW)&lt;br /&gt;
{&lt;br /&gt;
	if(EoW == &amp;quot;E&amp;quot;)		/* viene da est */&lt;br /&gt;
	{&lt;br /&gt;
		if(turn == 2 || est &amp;gt;=N || !empty(q))  &lt;br /&gt;
		{&lt;br /&gt;
			q=enqueue(&amp;quot;E&amp;quot;);		/*inserisco nella coda dei sensi*/	&lt;br /&gt;
			oktomove.wait();   	/*aspetta*/&lt;br /&gt;
									&lt;br /&gt;
		}&lt;br /&gt;
	turn = 1;	/*impongo il senso delle auto in circolo nel ponte */&lt;br /&gt;
	est++;&lt;br /&gt;
	}&lt;br /&gt;
	else		/* viene da ovest */&lt;br /&gt;
	{&lt;br /&gt;
		if(turn ==1 || ovest &amp;gt;=N || !empty(q))&lt;br /&gt;
		{&lt;br /&gt;
		        q=enqueue(&amp;quot;O&amp;quot;);		/*inserisco nella coda dei sensi*/&lt;br /&gt;
			oktomove.wait();	/*aspetta*/&lt;br /&gt;
									&lt;br /&gt;
		}&lt;br /&gt;
	turn = 2;	/*impongo il senso delle auto in circolo nel ponte */&lt;br /&gt;
	ovest++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
procedure entry exit(char EoW)&lt;br /&gt;
{&lt;br /&gt;
	char r;&lt;br /&gt;
	if(EoW == &amp;quot;O&amp;quot;)&lt;br /&gt;
	{&lt;br /&gt;
	est--;&lt;br /&gt;
	r=head(q);                          /* leggo la prossima auto che aspetta di entrare */&lt;br /&gt;
		if(est == 0 || r == &amp;quot;E&amp;quot;)     /*nessuna auto in transito nel ponte o il prossimo va nella stessa direzione*/&lt;br /&gt;
		{&lt;br /&gt;
		est--;&lt;br /&gt;
			if(est == 0)	/*nessuna auto in transito nel ponte */&lt;br /&gt;
			{&lt;br /&gt;
			turn = 0;	/*avanti un altro */&lt;br /&gt;
			}&lt;br /&gt;
			if(!empty(q))&lt;br /&gt;
			{&lt;br /&gt;
			q.dequeue();&lt;br /&gt;
			oktomove.signal();	/*segnale*/&lt;br /&gt;
			}&lt;br /&gt;
                }&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
	ovest--;&lt;br /&gt;
	r=head(q);                          /* leggo la prossima auto che aspetta di entrare */&lt;br /&gt;
		if(ovest == 0 || r == &amp;quot;O&amp;quot;)	 /*nessuna auto in transito nel ponte o il prossimo va nella stessa direzione*/&lt;br /&gt;
		{&lt;br /&gt;
		turn = 0;	/*avanti un altro */&lt;br /&gt;
		}&lt;br /&gt;
		if(!empty(q))&lt;br /&gt;
		{&lt;br /&gt;
		q.dequeue();		&lt;br /&gt;
		oktomove.signal();	/*segnale*/&lt;br /&gt;
	        }&lt;br /&gt;
        }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * URL: http://www.cs.unibo.it/~renzo/so/compiti/2014.01.22.tot.pdf&lt;br /&gt;
 * author: Tommaso Ognibene&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
monitor bridge&lt;br /&gt;
{&lt;br /&gt;
	condition okE;    // attraversare in direzione Est&lt;br /&gt;
	condition okW;    // attraversare in direzione Ovest&lt;br /&gt;
	int n = 0;        // numero di veicoli sul ponte&lt;br /&gt;
	int waitingE = 0; // numero di veicoli che attendono di attraversare in direzione Est&lt;br /&gt;
	int waitingW = 0; // numero di veicoli che attendono di attraversare in direzione Ovest&lt;br /&gt;
	bool toE = true;  // direzione di attraversamento&lt;br /&gt;
&lt;br /&gt;
	procedure entry enter(Vehicle vehicle)&lt;br /&gt;
	{&lt;br /&gt;
		// [Case 1] Il veicolo vuole attraversare in direzione Ovest&lt;br /&gt;
		if (vehicle.To == 'W')&lt;br /&gt;
		{&lt;br /&gt;
			/* Se - il numero di veicoli sul ponte ha raggiunto il massimo; oppure&lt;br /&gt;
			      - qualcuno sta attraversando in direzione opposta; oppure&lt;br /&gt;
			      - qualcuno sta attendendo di attraversare in direzione opposta */&lt;br /&gt;
			if (n == N || (toE &amp;amp;&amp;amp; n &amp;gt; 0) || (!toE &amp;amp;&amp;amp; waitingE &amp;gt; 0))&lt;br /&gt;
			{&lt;br /&gt;
				// Mi fermo e attendo di essere sbloccato&lt;br /&gt;
				waitingW++;&lt;br /&gt;
				okW.wait();&lt;br /&gt;
				waitingW--;&lt;br /&gt;
			}&lt;br /&gt;
			toE = false;&lt;br /&gt;
			n++;&lt;br /&gt;
			&lt;br /&gt;
			/* Se possibile, sblocco eventuali altri veicoli in attesa per la stessa direzione.&lt;br /&gt;
			 * Questo non crea starvation in quanto sono sicuramente un numero limitato. */&lt;br /&gt;
			if (n &amp;lt; N &amp;amp;&amp;amp; waitingE == 0)&lt;br /&gt;
				okW.signal();&lt;br /&gt;
		}&lt;br /&gt;
		// [Case 2] Il veicolo vuole attraversare in direzione Est&lt;br /&gt;
		else&lt;br /&gt;
		{&lt;br /&gt;
			/* Se - il numero di veicoli sul ponte ha raggiunto il massimo; oppure&lt;br /&gt;
			      - qualcuno sta attraversando in direzione opposta; oppure&lt;br /&gt;
			      - qualcuno sta attendendo di attraversare in direzione opposta */&lt;br /&gt;
			if (n == N || (!toE &amp;amp;&amp;amp; n &amp;gt; 0) || (toE &amp;amp;&amp;amp; waitingW &amp;gt; 0))&lt;br /&gt;
			{&lt;br /&gt;
			        // Mi fermo e attendo di essere sbloccato&lt;br /&gt;
				waitingE++;&lt;br /&gt;
				okE.wait();&lt;br /&gt;
				waitingE--;&lt;br /&gt;
			}&lt;br /&gt;
			toE = true;&lt;br /&gt;
			n++;&lt;br /&gt;
&lt;br /&gt;
			/* Se possibile, sblocco eventuali altri veicoli in attesa per la stessa direzione.&lt;br /&gt;
			 * Questo non crea starvation in quanto sono sicuramente un numero limitato. */&lt;br /&gt;
			if (n &amp;lt; N &amp;amp;&amp;amp; waitingW == 0)&lt;br /&gt;
				okE.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	procedure entry exit(Vehicle vehicle)&lt;br /&gt;
	{&lt;br /&gt;
		n--;&lt;br /&gt;
		/* Se nessuno sta attraversando il ponte */&lt;br /&gt;
		if (n == 0)&lt;br /&gt;
		{&lt;br /&gt;
			// [Case 1] L'ultimo ad attraversare andava in direzione Ovest&lt;br /&gt;
			if (vehicle.To == 'W')&lt;br /&gt;
			{&lt;br /&gt;
			   /* Se esiste, attivo il veicolo che per primo si era messo&lt;br /&gt;
			      in attesa per la direzione opposta */&lt;br /&gt;
			   if (waitingE &amp;gt; 0)&lt;br /&gt;
				okE.signal();&lt;br /&gt;
			   else&lt;br /&gt;
				okW.signal();&lt;br /&gt;
			}&lt;br /&gt;
			// [Case 2] L'ultimo ad attraversare andava in direzione Est&lt;br /&gt;
			else&lt;br /&gt;
			{&lt;br /&gt;
			   /* Se esiste, attivo il veicolo che per primo si era messo&lt;br /&gt;
		              in attesa per la direzione opposta */&lt;br /&gt;
			   if (waitingW &amp;gt; 0)&lt;br /&gt;
				okW.signal();&lt;br /&gt;
			   else&lt;br /&gt;
				okE.signal();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
La Mia soluzione:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * author: Midolo&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
Monitor Ponte {&lt;br /&gt;
#define O 0&lt;br /&gt;
#define E 1&lt;br /&gt;
condition oktocross[2];&lt;br /&gt;
int countwaiting[2], crossing;&lt;br /&gt;
&lt;br /&gt;
	bridge.enter(dir){&lt;br /&gt;
		if(crossing != 0 || countwaiting[1-dir] != 0){&lt;br /&gt;
			countwaiting[dir]++;&lt;br /&gt;
			oktocross[dir].wait();&lt;br /&gt;
			countwaiting[dir]--;            &lt;br /&gt;
		}&lt;br /&gt;
		crossing++;&lt;br /&gt;
		if(crossing &amp;lt; N){ &lt;br /&gt;
			oktocross[dir].signal();&lt;br /&gt;
		}    &lt;br /&gt;
	}&lt;br /&gt;
    &lt;br /&gt;
	bridge.exit(dir){&lt;br /&gt;
		crossing--;&lt;br /&gt;
		if(crossing == 0){&lt;br /&gt;
			if(countwaiting[dir] != 0){&lt;br /&gt;
				oktocross[dir].signal();&lt;br /&gt;
			}else{&lt;br /&gt;
				oktocross[1-dir].signal();&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
        &lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Esercizio g.1==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
&amp;quot;Punto a&amp;quot;&lt;br /&gt;
                123456789123456789123456789...&lt;br /&gt;
                 &lt;br /&gt;
                111111111111111111111111111&lt;br /&gt;
                 22222222222222222222222222          MIN e MAXNUM (finiti page fault)&lt;br /&gt;
                  3456789993456789993456789&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Punto b&amp;quot;&lt;br /&gt;
                123453453453453453453453453...&lt;br /&gt;
                 &lt;br /&gt;
                111111111111111111111111111&lt;br /&gt;
                 22222222222222222222222222          MIN e MAXNUM (page fault ad ogni accesso)&lt;br /&gt;
                  3453453453453453453453453&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight &amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=651</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=651"/>
		<updated>2014-04-30T15:46:20Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=644</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=644"/>
		<updated>2014-04-30T13:59:17Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.02.15.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:Espag.jpg]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=643</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=643"/>
		<updated>2014-04-30T13:56:40Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Questo &amp;amp;egrave; il Wiki del Corso di Sistemi Operativi&lt;br /&gt;
&lt;br /&gt;
[[Esercizi a caso del Prof.]]&lt;br /&gt;
&lt;br /&gt;
[[Decalogo di Programmazione Concorrente]]&lt;br /&gt;
&lt;br /&gt;
[[Python Programma tieni punteggio.]]&lt;br /&gt;
&lt;br /&gt;
[[Comandi visti alle lezioni.]]&lt;br /&gt;
&lt;br /&gt;
[[SYS CALL viste a lezione.]]&lt;br /&gt;
&lt;br /&gt;
[[Parametri con getopt().]]&lt;br /&gt;
&lt;br /&gt;
[[Funzione con numero variabile di parametri.]]&lt;br /&gt;
&lt;br /&gt;
[[stampf - implementazione ridotta della printf.]]&lt;br /&gt;
&lt;br /&gt;
[[Producer&amp;amp;Consumer MP.]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2014.01.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.09.13]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.07.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.05.29]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.01.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.09.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2005.02.10]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2011.07.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.02.09]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.05.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.06.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2011.02.11]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.01.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2014.01.22]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2012.07.16]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica_2010.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.01.16]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2009.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.09.17]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.09.07]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.02.03]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.02.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.01.15]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2011.01.17]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2010.05.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2012.01.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.09.23]]&lt;br /&gt;
----&lt;br /&gt;
Ricordate che per creare un account o quando viene richiesto di risolvere un semplice calcolo occorre ricordare quanto scritto [[qui]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=641</id>
		<title>ProvaTeorica 2013.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.05.30&amp;diff=641"/>
		<updated>2014-04-30T13:53:57Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Created page with &amp;quot;&amp;lt;h1&amp;gt; Esercizio 1g &amp;lt;/h1&amp;gt; File:espag.jpg&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt; Esercizio 1g &amp;lt;/h1&amp;gt;&lt;br /&gt;
[[File:espag.jpg]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=639</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=639"/>
		<updated>2014-04-30T13:51:07Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Questo &amp;amp;egrave; il Wiki del Corso di Sistemi Operativi&lt;br /&gt;
&lt;br /&gt;
[[Esercizi a caso del Prof.]]&lt;br /&gt;
&lt;br /&gt;
[[Decalogo di Programmazione Concorrente]]&lt;br /&gt;
&lt;br /&gt;
[[Python Programma tieni punteggio.]]&lt;br /&gt;
&lt;br /&gt;
[[Comandi visti alle lezioni.]]&lt;br /&gt;
&lt;br /&gt;
[[SYS CALL viste a lezione.]]&lt;br /&gt;
&lt;br /&gt;
[[Parametri con getopt().]]&lt;br /&gt;
&lt;br /&gt;
[[Funzione con numero variabile di parametri.]]&lt;br /&gt;
&lt;br /&gt;
[[stampf - implementazione ridotta della printf.]]&lt;br /&gt;
&lt;br /&gt;
[[Producer&amp;amp;Consumer MP.]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2014.01.23]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.09.13]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.07.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.05.29]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.02.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2013.01.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2012.09.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2005.02.10]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria_2011.07.25]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.02.09]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.05.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.06.15]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2012.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2013.05.30]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica_2011.02.11]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.07.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2013.01.24]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2014.01.22]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeorica 2012.07.16]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica_2010.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.01.16]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2009.09.18]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2008.09.17]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.09.07]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2013.06.21]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2010.02.03]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.09.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.02.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2009.01.15]]&lt;br /&gt;
&lt;br /&gt;
[[Prova Teorica 2007.07.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2011.01.17]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2010.05.12]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaTeoria 2012.01.12]]&lt;br /&gt;
----&lt;br /&gt;
Ricordate che per creare un account o quando viene richiesto di risolvere un semplice calcolo occorre ricordare quanto scritto [[qui]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=622</id>
		<title>ProvaTeorica 2013.02.15</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.02.15&amp;diff=622"/>
		<updated>2014-04-29T18:41:05Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Esercizio c.1: (a) Scrivere un monitor dualwriter che realizzi un doppio buffer limitato (ogni buffer ha ampiezza&lt;br /&gt;
BUFSIZE) che consenta a uno scrittore di scrivere contemporaneamente due elementi che andranno rispettivamente&lt;br /&gt;
nel primo e nel secondo buffer. Le letture :&lt;br /&gt;
 procedure entry void write(type1 e1, type2 e2);&lt;br /&gt;
 procedure entry type1 read1();&lt;br /&gt;
 procedure entry type2 read2();&lt;br /&gt;
La funzione write deve attendere che ci sia spazio in entrambi i buffer. &lt;br /&gt;
La funzione read attende che vi sia almeno un elemento nel buffer indicato&lt;br /&gt;
*/&lt;br /&gt;
monitor dualwriter&lt;br /&gt;
{&lt;br /&gt;
	type1* buffer1;&lt;br /&gt;
	type2* buffer2;&lt;br /&gt;
	condition oktowrite,oktoread1, oktoread2&lt;br /&gt;
	procedure entry void write (type1 e1, type2 e2)&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(type1)&amp;gt;=BUFSIZE || sizeof(type2)&amp;gt;=BUFSIZE)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		buffer1.push(e1);&lt;br /&gt;
		buffer2.push(e2);&lt;br /&gt;
		oktoread1.signal();&lt;br /&gt;
		oktoread2.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type1 read1()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer1)==0)&lt;br /&gt;
			oktoread1.wait();&lt;br /&gt;
		buffer1.pop();&lt;br /&gt;
		if (sizeof(buffer2)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	procedure entry type2 read2()&lt;br /&gt;
	{&lt;br /&gt;
		if (sizeof(buffer2)==0)&lt;br /&gt;
			oktoread2.wait();&lt;br /&gt;
		buffer2.pop();&lt;br /&gt;
		if (sizeof(buffer1)&amp;lt;BUFSIZE)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
-stefano92&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:Espag.jpg]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:Espag.jpg&amp;diff=621</id>
		<title>File:Espag.jpg</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:Espag.jpg&amp;diff=621"/>
		<updated>2014-04-29T18:39:25Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=616</id>
		<title>Prova Teorica 2013.06.21</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=616"/>
		<updated>2014-04-28T15:02:00Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.06.21.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[http://so.v2.cs.unibo.it/wiki/images/0/02/G1paginazione.jpg soluzione]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=615</id>
		<title>Prova Teorica 2013.06.21</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=615"/>
		<updated>2014-04-28T14:59:41Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.06.21.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:G1paginazione.jpg]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=614</id>
		<title>Prova Teorica 2013.06.21</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=614"/>
		<updated>2014-04-28T14:53:06Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.06.21.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=613</id>
		<title>File:G1paginazione.jpg</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=613"/>
		<updated>2014-04-28T14:35:55Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Stanislao uploaded a new version of &amp;amp;quot;File:G1paginazione.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=612</id>
		<title>File:G1paginazione.jpg</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=612"/>
		<updated>2014-04-28T14:33:27Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Stanislao uploaded a new version of &amp;amp;quot;File:G1paginazione.jpg&amp;amp;quot;: Reverted to version as of 14:30, 28 April 2014&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=611</id>
		<title>File:G1paginazione.jpg</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=611"/>
		<updated>2014-04-28T14:33:08Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Stanislao uploaded a new version of &amp;amp;quot;File:G1paginazione.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=610</id>
		<title>File:G1paginazione.jpg</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=File:G1paginazione.jpg&amp;diff=610"/>
		<updated>2014-04-28T14:30:45Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: Stanislao uploaded a new version of &amp;amp;quot;File:G1paginazione.jpg&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=600</id>
		<title>Prova Teorica 2013.06.21</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=Prova_Teorica_2013.06.21&amp;diff=600"/>
		<updated>2014-04-28T13:30:32Z</updated>

		<summary type="html">&lt;p&gt;Stanislao: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;h1&amp;gt;[http://www.cs.unibo.it/~renzo/so/compiti/2013.06.21.tot.pdf Testo del compito]&amp;lt;/h1&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt; Esercizio g.1 &amp;lt;/h2&amp;gt;&lt;br /&gt;
[[File:G1paginazione.jpg]]&lt;/div&gt;</summary>
		<author><name>Stanislao</name></author>
	</entry>
</feed>