<?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=Gab</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=Gab"/>
	<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php/Special:Contributions/Gab"/>
	<updated>2026-04-30T16:36:05Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.5</generator>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.05.30&amp;diff=745</id>
		<title>ProvaPratica 2011.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.05.30&amp;diff=745"/>
		<updated>2014-05-19T21:09:27Z</updated>

		<summary type="html">&lt;p&gt;Gab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cs.unibo.it/~renzo/so/pratiche/2011.05.30.pdf Link to exam]&lt;br /&gt;
&lt;br /&gt;
Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
sender.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define COMMUNICATION_SIGNAL 25&lt;br /&gt;
#define MAXIMUM_LENGTH 4096&lt;br /&gt;
&lt;br /&gt;
#define PID_LENGTH 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedPID&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*PID_LENGTH);&lt;br /&gt;
	char *sharedVariable = mmap(NULL,sizeof(char)*PID_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	int effectivePID = atoi(sharedVariable);&lt;br /&gt;
	int sharedParametersFD = shm_open(&amp;quot;/sharedParameters&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedParametersFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedParametersFD,sizeof(char)*MAXIMUM_LENGTH);&lt;br /&gt;
	char *parameters = mmap(NULL,sizeof(char)*MAXIMUM_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedParametersFD,0);&lt;br /&gt;
	char parametersToPass[MAXIMUM_LENGTH];&lt;br /&gt;
	int i;&lt;br /&gt;
	for(i=0;i&amp;lt;MAXIMUM_LENGTH;i++)&lt;br /&gt;
		parametersToPass[i]='\0';&lt;br /&gt;
	for(i=0;i&amp;lt;argc;i++)&lt;br /&gt;
	{&lt;br /&gt;
		strcat(parametersToPass,argv[i]);&lt;br /&gt;
		strcat(parametersToPass,&amp;quot;\n&amp;quot;);&lt;br /&gt;
	}	&lt;br /&gt;
	strcpy(parameters,parametersToPass);&lt;br /&gt;
	kill(effectivePID,COMMUNICATION_SIGNAL);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
receiver.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define COMMUNICATION_SIGNAL 25&lt;br /&gt;
&lt;br /&gt;
#define MAXIMUM_LENGTH 4096&lt;br /&gt;
&lt;br /&gt;
#define PID_LENGTH 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void signalHandler (int sig, siginfo_t *siginfo, void *context)&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedParameters&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*MAXIMUM_LENGTH);&lt;br /&gt;
	char *parameters = mmap(NULL,sizeof(char)*MAXIMUM_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	printf(&amp;quot;Parameters: %s&amp;quot;,parameters);&lt;br /&gt;
	exit(0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedPID&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	char *currentPIDToPass; 	&lt;br /&gt;
	asprintf(&amp;amp;currentPIDToPass,&amp;quot;%d&amp;quot;,getpid());&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*PID_LENGTH);&lt;br /&gt;
	char *sharedVariable = mmap(NULL,sizeof(char)*PID_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	strcpy(sharedVariable,currentPIDToPass);&lt;br /&gt;
	struct sigaction signalStruct;&lt;br /&gt;
	signalStruct.sa_sigaction = &amp;amp;signalHandler;&lt;br /&gt;
	sigaction(COMMUNICATION_SIGNAL,&amp;amp;signalStruct,NULL);&lt;br /&gt;
	while(1){}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Gab&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.05.30&amp;diff=744</id>
		<title>ProvaPratica 2011.05.30</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2011.05.30&amp;diff=744"/>
		<updated>2014-05-19T21:09:12Z</updated>

		<summary type="html">&lt;p&gt;Gab: Created page with &amp;quot;[http://www.cs.unibo.it/~renzo/so/pratiche/2011.05.30.pdf Link to exam]  Esercizio 1   sender.c  &amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt; #include &amp;lt;stdlib.h&amp;gt; #include &amp;lt;stdio.h&amp;gt; #include &amp;lt;un...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cs.unibo.it/~renzo/so/pratiche/2011.05.30.pdf Link to exam]&lt;br /&gt;
&lt;br /&gt;
Esercizio 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
sender.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define COMMUNICATION_SIGNAL 25&lt;br /&gt;
#define MAXIMUM_LENGTH 4096&lt;br /&gt;
&lt;br /&gt;
#define PID_LENGTH 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedPID&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*PID_LENGTH);&lt;br /&gt;
	char *sharedVariable = mmap(NULL,sizeof(char)*PID_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	int effectivePID = atoi(sharedVariable);&lt;br /&gt;
	int sharedParametersFD = shm_open(&amp;quot;/sharedParameters&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedParametersFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedParametersFD,sizeof(char)*MAXIMUM_LENGTH);&lt;br /&gt;
	char *parameters = mmap(NULL,sizeof(char)*MAXIMUM_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedParametersFD,0);&lt;br /&gt;
	char parametersToPass[MAXIMUM_LENGTH];&lt;br /&gt;
	int i;&lt;br /&gt;
	for(i=0;i&amp;lt;MAXIMUM_LENGTH;i++)&lt;br /&gt;
		parametersToPass[i]='\0';&lt;br /&gt;
	for(i=0;i&amp;lt;argc;i++)&lt;br /&gt;
	{&lt;br /&gt;
		strcat(parametersToPass,argv[i]);&lt;br /&gt;
		strcat(parametersToPass,&amp;quot;\n&amp;quot;);&lt;br /&gt;
	}	&lt;br /&gt;
	strcpy(parameters,parametersToPass);&lt;br /&gt;
	kill(effectivePID,COMMUNICATION_SIGNAL);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
receiver.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/mman.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define COMMUNICATION_SIGNAL 25&lt;br /&gt;
&lt;br /&gt;
#define MAXIMUM_LENGTH 4096&lt;br /&gt;
&lt;br /&gt;
#define PID_LENGTH 10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
static void signalHandler (int sig, siginfo_t *siginfo, void *context)&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedParameters&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*MAXIMUM_LENGTH);&lt;br /&gt;
	char *parameters = mmap(NULL,sizeof(char)*MAXIMUM_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	printf(&amp;quot;Parameters: %s&amp;quot;,parameters);&lt;br /&gt;
	exit(0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	int sharedFD = shm_open(&amp;quot;/sharedPID&amp;quot;, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR);&lt;br /&gt;
	if(!sharedFD)&lt;br /&gt;
		return;&lt;br /&gt;
	char *currentPIDToPass; 	&lt;br /&gt;
	asprintf(&amp;amp;currentPIDToPass,&amp;quot;%d&amp;quot;,getpid());&lt;br /&gt;
	ftruncate(sharedFD,sizeof(char)*PID_LENGTH);&lt;br /&gt;
	char *sharedVariable = mmap(NULL,sizeof(char)*PID_LENGTH,PROT_READ | PROT_WRITE,MAP_SHARED,sharedFD,0);&lt;br /&gt;
	strcpy(sharedVariable,currentPIDToPass);&lt;br /&gt;
	struct sigaction signalStruct;&lt;br /&gt;
	signalStruct.sa_sigaction = &amp;amp;signalHandler;&lt;br /&gt;
	sigaction(COMMUNICATION_SIGNAL,&amp;amp;signalStruct,NULL);&lt;br /&gt;
	while(1){}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=743</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=743"/>
		<updated>2014-05-19T21:05:00Z</updated>

		<summary type="html">&lt;p&gt;Gab: &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 2012.07.17]]&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;
[[ProvaTeorica 2005.11.04]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.01.19]]&lt;br /&gt;
&lt;br /&gt;
[[ProvaPratica 2011.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>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2010.07.19&amp;diff=654</id>
		<title>ProvaPratica 2010.07.19</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2010.07.19&amp;diff=654"/>
		<updated>2014-05-01T21:46:55Z</updated>

		<summary type="html">&lt;p&gt;Gab: Created page with &amp;quot;[http://www.cs.unibo.it/~renzo/so/pratiche/2010-07-19.pdf Link to exam]  Esercizio1  &amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt; #include &amp;quot;stdlib.h&amp;quot; #include &amp;quot;stdio.h&amp;quot; #include &amp;quot;unistd.h&amp;quot; #inc...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cs.unibo.it/~renzo/so/pratiche/2010-07-19.pdf Link to exam]&lt;br /&gt;
&lt;br /&gt;
Esercizio1&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
#include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
#include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
#include &amp;quot;string.h&amp;quot;&lt;br /&gt;
#include &amp;lt;sys/time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define MESSAGE_LENGTH 40&lt;br /&gt;
#define NUMBER_OF_MESSAGE 100000&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *arv[])&lt;br /&gt;
{&lt;br /&gt;
	int childToParentPipe[2];&lt;br /&gt;
	int parentToChildPipe[2];&lt;br /&gt;
	pipe(childToParentPipe);&lt;br /&gt;
	pipe(parentToChildPipe);&lt;br /&gt;
	int childPID = fork();&lt;br /&gt;
	if(childPID)&lt;br /&gt;
	{&lt;br /&gt;
		/* parent */&lt;br /&gt;
		int toReadDescriptor = childToParentPipe[0];&lt;br /&gt;
		int toWriteDescriptor = parentToChildPipe[1];&lt;br /&gt;
		close(childToParentPipe[1]);&lt;br /&gt;
		close(parentToChildPipe[0]);&lt;br /&gt;
		char messageToSend[MESSAGE_LENGTH];&lt;br /&gt;
		int index = 0;&lt;br /&gt;
		for(index = 0 ; index&amp;lt;MESSAGE_LENGTH;index++)&lt;br /&gt;
			messageToSend[index] = 'M';&lt;br /&gt;
		messageToSend[MESSAGE_LENGTH-1]='\0';&lt;br /&gt;
		char messageToRead[MESSAGE_LENGTH];&lt;br /&gt;
		struct timeval startTime;&lt;br /&gt;
		struct timeval endTime;&lt;br /&gt;
		gettimeofday(&amp;amp;startTime,NULL);&lt;br /&gt;
		for(index = 0;index &amp;lt;NUMBER_OF_MESSAGE;index++ )&lt;br /&gt;
		{&lt;br /&gt;
			write(toWriteDescriptor,messageToSend,MESSAGE_LENGTH);&lt;br /&gt;
			read(toReadDescriptor,&amp;amp;messageToRead,MESSAGE_LENGTH);&lt;br /&gt;
		}&lt;br /&gt;
		gettimeofday(&amp;amp;endTime,NULL);&lt;br /&gt;
		struct timeval timeUsed;&lt;br /&gt;
		timersub(&amp;amp;endTime,&amp;amp;startTime,&amp;amp;timeUsed);&lt;br /&gt;
		printf(&amp;quot;Time taken %ld seconds and %d useconds \n&amp;quot;, timeUsed.tv_sec, timeUsed.tv_usec);&lt;br /&gt;
		kill(childPID,SIGTERM);&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		/* child */&lt;br /&gt;
		int toReadDescriptor = parentToChildPipe[0];&lt;br /&gt;
		int toWriteDescriptor = childToParentPipe[1];&lt;br /&gt;
		close(childToParentPipe[0]);&lt;br /&gt;
		close(parentToChildPipe[1]);&lt;br /&gt;
		char arrivedMessage[MESSAGE_LENGTH];&lt;br /&gt;
		while(1)&lt;br /&gt;
		{&lt;br /&gt;
			read(toReadDescriptor,arrivedMessage,MESSAGE_LENGTH);&lt;br /&gt;
			write(toWriteDescriptor,arrivedMessage,strlen(arrivedMessage));&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Esercizio2&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdlib.h&amp;quot;&lt;br /&gt;
#include &amp;quot;stdio.h&amp;quot;&lt;br /&gt;
#include &amp;quot;unistd.h&amp;quot;&lt;br /&gt;
#include &amp;quot;string.h&amp;quot;&lt;br /&gt;
#include &amp;lt;sys/time.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/ipc.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/msg.h&amp;gt;&lt;br /&gt;
#include &amp;lt;signal.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define MESSAGE_LENGTH 40&lt;br /&gt;
#define NUMBER_OF_MESSAGE 100000&lt;br /&gt;
&lt;br /&gt;
#define PARENT_TO_CHILD_TAG 1&lt;br /&gt;
&lt;br /&gt;
#define CHILD_TO_PARENT_TAG 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
typedef struct MessageBody&lt;br /&gt;
{&lt;br /&gt;
	long type;&lt;br /&gt;
	char message[MESSAGE_LENGTH];&lt;br /&gt;
} MessageBody;&lt;br /&gt;
&lt;br /&gt;
int main(int argc,char *arv[])&lt;br /&gt;
{&lt;br /&gt;
	int messageQueueID = msgget(IPC_PRIVATE, 0666);&lt;br /&gt;
	int childPID = fork();&lt;br /&gt;
	if(childPID)&lt;br /&gt;
	{&lt;br /&gt;
		/* parent */&lt;br /&gt;
		MessageBody messageToSend;&lt;br /&gt;
		messageToSend.type = 1;&lt;br /&gt;
		int index;&lt;br /&gt;
		for(index = 0;index&amp;lt;MESSAGE_LENGTH;index++)&lt;br /&gt;
			messageToSend.message[index] = 'M';&lt;br /&gt;
		messageToSend.message[MESSAGE_LENGTH-1] = '\0';&lt;br /&gt;
		MessageBody messageReceived;&lt;br /&gt;
		struct timeval startTime;&lt;br /&gt;
		struct timeval endTime;&lt;br /&gt;
		gettimeofday(&amp;amp;startTime,NULL);&lt;br /&gt;
		for(index = 0;index &amp;lt; NUMBER_OF_MESSAGE;index++)&lt;br /&gt;
		{&lt;br /&gt;
			msgsnd(messageQueueID,&amp;amp;messageToSend,MESSAGE_LENGTH,0);&lt;br /&gt;
			msgrcv(messageQueueID,&amp;amp;messageReceived,MESSAGE_LENGTH,2,MSG_NOERROR);&lt;br /&gt;
		}&lt;br /&gt;
		gettimeofday(&amp;amp;endTime,NULL);&lt;br /&gt;
		struct timeval timeUsed;&lt;br /&gt;
		timersub(&amp;amp;endTime,&amp;amp;startTime,&amp;amp;timeUsed);&lt;br /&gt;
		printf(&amp;quot;Time taken %ld seconds and %d useconds \n&amp;quot;, timeUsed.tv_sec, timeUsed.tv_usec);&lt;br /&gt;
		kill(childPID,SIGTERM);&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{&lt;br /&gt;
		/* child */&lt;br /&gt;
		while(1)&lt;br /&gt;
		{&lt;br /&gt;
			MessageBody messageReceived;&lt;br /&gt;
			msgrcv(messageQueueID,&amp;amp;messageReceived,MESSAGE_LENGTH,1,MSG_NOERROR);&lt;br /&gt;
			messageReceived.type = 2;&lt;br /&gt;
			msgsnd(messageQueueID,&amp;amp;messageReceived,MESSAGE_LENGTH,0);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gab&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=653</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=653"/>
		<updated>2014-05-01T21:42:39Z</updated>

		<summary type="html">&lt;p&gt;Gab: &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;
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>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2012.06.20&amp;diff=652</id>
		<title>ProvaPratica 2012.06.20</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2012.06.20&amp;diff=652"/>
		<updated>2014-05-01T21:39:29Z</updated>

		<summary type="html">&lt;p&gt;Gab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cs.unibo.it/~renzo/so/pratiche/2012.06.20.pdf Link to Exam]&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;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/wait.h&amp;gt;&lt;br /&gt;
#include &amp;lt;linux/inotify.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main (int arc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
	if(arc&amp;lt;2)&lt;br /&gt;
		return 0;&lt;br /&gt;
	char *directoryToWatch;&lt;br /&gt;
	directoryToWatch = argv[1]+1;&lt;br /&gt;
	int notifierDescriptor = inotify_init();&lt;br /&gt;
	if(!notifierDescriptor)&lt;br /&gt;
	{&lt;br /&gt;
		perror(&amp;quot;inotify_init&amp;quot;);&lt;br /&gt;
		return 0;		&lt;br /&gt;
	}&lt;br /&gt;
	int watcherDescriptor = inotify_add_watch( notifierDescriptor,directoryToWatch, IN_CREATE);&lt;br /&gt;
	char eventBuffer[sizeof(struct inotify_event)+256];&lt;br /&gt;
	while(read(notifierDescriptor,eventBuffer,sizeof(struct inotify_event)+256)&amp;gt;0)&lt;br /&gt;
	{&lt;br /&gt;
		struct inotify_event *event = ( struct inotify_event * ) eventBuffer;&lt;br /&gt;
		if ( event-&amp;gt;mask &amp;amp; IN_CREATE ) &lt;br /&gt;
		{&lt;br /&gt;
     		   	if ( event-&amp;gt;mask &amp;amp; IN_ISDIR ) &lt;br /&gt;
        			  printf( &amp;quot;directory %s created.\n&amp;quot;, event-&amp;gt;name );&lt;br /&gt;
		   	else&lt;br /&gt;
			{&lt;br /&gt;
				struct stat fileStructure;			&lt;br /&gt;
				char fileName[strlen(directoryToWatch)+strlen(event-&amp;gt;name)+1];&lt;br /&gt;
				strcpy(fileName,directoryToWatch);&lt;br /&gt;
				strcat(fileName,&amp;quot;/&amp;quot;);&lt;br /&gt;
				strcat(fileName,event-&amp;gt;name);&lt;br /&gt;
				int result = stat(fileName,&amp;amp;fileStructure);&lt;br /&gt;
				if(result&amp;lt;0)&lt;br /&gt;
				{&lt;br /&gt;
					return 0;				&lt;br /&gt;
				}&lt;br /&gt;
				if(S_IEXEC &amp;amp;&amp;amp; fileStructure.st_mode)&lt;br /&gt;
				{	&lt;br /&gt;
					int resultFromFork = fork();&lt;br /&gt;
					if(!resultFromFork)&lt;br /&gt;
					{&lt;br /&gt;
						//child&lt;br /&gt;
						int result = execl(fileName,event-&amp;gt;name,(char *)0);&lt;br /&gt;
						if(result&amp;lt;0)&lt;br /&gt;
							 printf(&amp;quot;an error: %s\n&amp;quot;, strerror(errno));&lt;br /&gt;
					}	&lt;br /&gt;
					else&lt;br /&gt;
					{&lt;br /&gt;
						&lt;br /&gt;
						if(waitpid(-1,NULL,0))&lt;br /&gt;
							unlink(fileName);&lt;br /&gt;
						&lt;br /&gt;
					}				&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
        	}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	inotify_rm_watch( notifierDescriptor, watcherDescriptor );&lt;br /&gt;
	close(notifierDescriptor);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Gab&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2012.06.20&amp;diff=650</id>
		<title>ProvaPratica 2012.06.20</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaPratica_2012.06.20&amp;diff=650"/>
		<updated>2014-04-30T15:06:04Z</updated>

		<summary type="html">&lt;p&gt;Gab: Created page with &amp;quot;[http://www.cs.unibo.it/~renzo/so/pratiche/2012.06.20.pdf Link to Exam]   &amp;lt;syntaxhighlight lang=&amp;quot;C&amp;quot;&amp;gt;  #include &amp;lt;stdlib.h&amp;gt; #include &amp;lt;stdio.h&amp;gt; #include &amp;lt;string.h&amp;gt; #include &amp;lt;unis...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://www.cs.unibo.it/~renzo/so/pratiche/2012.06.20.pdf Link to Exam]&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;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;lt;errno.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#include &amp;lt;sys/wait.h&amp;gt;&lt;br /&gt;
#include &amp;lt;linux/inotify.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
int main (int arc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
	if(arc&amp;lt;2)&lt;br /&gt;
		return 0;&lt;br /&gt;
	char *directoryToWatch;&lt;br /&gt;
	directoryToWatch = argv[1]+1;&lt;br /&gt;
	int notifierDescriptor = inotify_init();&lt;br /&gt;
	if(!notifierDescriptor)&lt;br /&gt;
	{&lt;br /&gt;
		perror(&amp;quot;inotify_init&amp;quot;);&lt;br /&gt;
		return 0;		&lt;br /&gt;
	}&lt;br /&gt;
	int watcherDescriptor = inotify_add_watch( notifierDescriptor,directoryToWatch, IN_CREATE);&lt;br /&gt;
	char eventBuffer[sizeof(struct inotify_event)+256];&lt;br /&gt;
	while(read(notifierDescriptor,eventBuffer,sizeof(struct inotify_event)+256)&amp;gt;0)&lt;br /&gt;
	{&lt;br /&gt;
		struct inotify_event *event = ( struct inotify_event * ) eventBuffer;&lt;br /&gt;
		if ( event-&amp;gt;mask &amp;amp; IN_CREATE ) &lt;br /&gt;
		{&lt;br /&gt;
     		   	if ( event-&amp;gt;mask &amp;amp; IN_ISDIR ) &lt;br /&gt;
        			  printf( &amp;quot;directory %s created.\n&amp;quot;, event-&amp;gt;name );&lt;br /&gt;
		   	else&lt;br /&gt;
			{&lt;br /&gt;
				struct stat fileStructure;			&lt;br /&gt;
				char fileName[strlen(directoryToWatch)+strlen(event-&amp;gt;name)+1];&lt;br /&gt;
				strcpy(fileName,directoryToWatch);&lt;br /&gt;
				strcat(fileName,&amp;quot;/&amp;quot;);&lt;br /&gt;
				strcat(fileName,event-&amp;gt;name);&lt;br /&gt;
				int result = stat(fileName,&amp;amp;fileStructure);&lt;br /&gt;
				if(result&amp;lt;0)&lt;br /&gt;
				{&lt;br /&gt;
					return 0;				&lt;br /&gt;
				}&lt;br /&gt;
				if(S_IEXEC &amp;amp;&amp;amp; fileStructure.st_mode)&lt;br /&gt;
				{	&lt;br /&gt;
					int resultFromFork = fork();&lt;br /&gt;
					if(!resultFromFork)&lt;br /&gt;
					{&lt;br /&gt;
						//child&lt;br /&gt;
						int result = execl(fileName,event-&amp;gt;name,(char *)0);&lt;br /&gt;
						if(result&amp;lt;0)&lt;br /&gt;
							 printf(&amp;quot;an error: %s\n&amp;quot;, strerror(errno));&lt;br /&gt;
					}	&lt;br /&gt;
					else&lt;br /&gt;
					{&lt;br /&gt;
						&lt;br /&gt;
						if(waitpid(-1,NULL,0))&lt;br /&gt;
							unlink(fileName);&lt;br /&gt;
						&lt;br /&gt;
					}				&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
        	}&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	inotify_rm_watch( notifierDescriptor, watcherDescriptor );&lt;br /&gt;
	close(notifierDescriptor);&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Gab&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=Main_Page&amp;diff=648</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=648"/>
		<updated>2014-04-30T15:01:14Z</updated>

		<summary type="html">&lt;p&gt;Gab: &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;
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>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.01.24&amp;diff=474</id>
		<title>ProvaTeorica 2013.01.24</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.01.24&amp;diff=474"/>
		<updated>2014-03-19T08:22:59Z</updated>

		<summary type="html">&lt;p&gt;Gab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Esercizio C1:&lt;br /&gt;
(a) Scrivere un monitor nmbb che realizzi un buffer limitato (di ampiezza BUFSIZE) che consenta alle&lt;br /&gt;
chiamate write (inserimento nel buffer) e read (lettura da buffer) di operare su vettori di piu' elementi. In particolare&lt;br /&gt;
l'interfaccia delle procedure entry da implementare e' la seguente:&lt;br /&gt;
procedure entry write(int n, struct elem *v);&lt;br /&gt;
procedure entry read(int m, struct elem *w);&lt;br /&gt;
se n o m sono maggiori di BUFSIZE le funzioni non devono fare nulla (caso di errore).&lt;br /&gt;
La funzione write deve attendere che ci sia spazio nel buffer per inserire n elementi (il vettore v conterra' n elementi).&lt;br /&gt;
Solo quando e' possibile completare l'operazione vengono inseriti tutti gli elementi di v nel buffer.&lt;br /&gt;
La funzione read attende che vi siano almeno m elementi nel buffer quindi estrae dal buffer (in ordine FIFO) m elementi e li copia nel vettore w .&lt;br /&gt;
(b) sono possibili casi di deadlock? (motivare dettagliatamente la risposta)&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;
read(): legge dalla coda un elemento senza rimuoverlo&lt;br /&gt;
queue(elem v,int n): inserisce nella coda n elementi v;&lt;br /&gt;
dequeue(int n): legge n elementi dalla coda e li rimuove;&lt;br /&gt;
&lt;br /&gt;
monitor  mnbb{&lt;br /&gt;
	conditon oktowrite, oktoread;&lt;br /&gt;
	queue qwrite,qread;&lt;br /&gt;
&lt;br /&gt;
	procedure entry write(int n, struct elem *v){&lt;br /&gt;
		if(n &amp;gt; BUFSIZE){&lt;br /&gt;
			return(ERROR);&lt;br /&gt;
		}&lt;br /&gt;
		if( n &amp;gt; (BUFSIZE - buff.lengh)){&lt;br /&gt;
			qwrite.queue( n, 1 );&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		}&lt;br /&gt;
		buff.queue( v, n );&lt;br /&gt;
		if(qread.read() &amp;lt;= buff.lengh){&lt;br /&gt;
			qread.dequeue(1);&lt;br /&gt;
			oktoread.signal();&lt;br /&gt;
		}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
	procedure entry read(int m, struct elem *w){&lt;br /&gt;
		if(m &amp;gt; BUFSIZE){&lt;br /&gt;
			return(ERROR);&lt;br /&gt;
		} &lt;br /&gt;
		if(m &amp;gt; buff.lengh){&lt;br /&gt;
			qread.queue( m, 1 );&lt;br /&gt;
			oktoread.wait();&lt;br /&gt;
		}&lt;br /&gt;
		w = buff.dequeue(m);&lt;br /&gt;
		if(qwrite.read() &amp;lt;= (BUFSIZE - buff.lengh)){&lt;br /&gt;
			qwrite.dequeue(1);&lt;br /&gt;
			oktowirte.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
- Midolo&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 nmbb{&lt;br /&gt;
	queue buffer;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread;&lt;br /&gt;
	&lt;br /&gt;
	/* assumiamo che essendo un buffer limitato ci sia un solo processo che vuole scrivere e un solo processo che vuole leggere */&lt;br /&gt;
	int N, M;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry write(int n, struct elem *v){&lt;br /&gt;
		if(n&amp;gt;BUFSIZE) return;&lt;br /&gt;
		N=n;&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;lt; N)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		for(i=0; i&amp;lt;N; i++)&lt;br /&gt;
			buffer.enqueue(v[i]);&lt;br /&gt;
			&lt;br /&gt;
		if(buffer.len &amp;gt;= M)&lt;br /&gt;
			oktoread.signal();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	procedure entry read(int m, struct elem *w){&lt;br /&gt;
		if(m&amp;gt;BUFSIZE) return;&lt;br /&gt;
		M=m;&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;lt; M)&lt;br /&gt;
			oktoread.wait();&lt;br /&gt;
		&lt;br /&gt;
		for(i=0; i&amp;lt;M; i++)&lt;br /&gt;
			w[i] = buffer.dequeue;&lt;br /&gt;
		&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;gt;= N)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Si può verificare deadlock. Esempio: un lettore vuole leggere un tot di elementi, ma quelli presenti non sono sufficienti. Uno scrittore a sua volta non può più scrivere un certo numero di elementi in quanto il buffer è parzialmente occupato. Lo scrittore aspetterà che il lettore legga; il lettore aspetterà invece lo scrittore: deadlock.&lt;br /&gt;
&lt;br /&gt;
Gabriele e Giulia&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
	<entry>
		<id>https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.01.24&amp;diff=473</id>
		<title>ProvaTeorica 2013.01.24</title>
		<link rel="alternate" type="text/html" href="https://so.v2.cs.unibo.it/wiki/index.php?title=ProvaTeorica_2013.01.24&amp;diff=473"/>
		<updated>2014-03-19T08:21:52Z</updated>

		<summary type="html">&lt;p&gt;Gab: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Esercizio C1:&lt;br /&gt;
(a) Scrivere un monitor nmbb che realizzi un buffer limitato (di ampiezza BUFSIZE) che consenta alle&lt;br /&gt;
chiamate write (inserimento nel buffer) e read (lettura da buffer) di operare su vettori di piu' elementi. In particolare&lt;br /&gt;
l'interfaccia delle procedure entry da implementare e' la seguente:&lt;br /&gt;
procedure entry write(int n, struct elem *v);&lt;br /&gt;
procedure entry read(int m, struct elem *w);&lt;br /&gt;
se n o m sono maggiori di BUFSIZE le funzioni non devono fare nulla (caso di errore).&lt;br /&gt;
La funzione write deve attendere che ci sia spazio nel buffer per inserire n elementi (il vettore v conterra' n elementi).&lt;br /&gt;
Solo quando e' possibile completare l'operazione vengono inseriti tutti gli elementi di v nel buffer.&lt;br /&gt;
La funzione read attende che vi siano almeno m elementi nel buffer quindi estrae dal buffer (in ordine FIFO) m elementi e li copia nel vettore w .&lt;br /&gt;
(b) sono possibili casi di deadlock? (motivare dettagliatamente la risposta)&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;
read(): legge dalla coda un elemento senza rimuoverlo&lt;br /&gt;
queue(elem v,int n): inserisce nella coda n elementi v;&lt;br /&gt;
dequeue(int n): legge n elementi dalla coda e li rimuove;&lt;br /&gt;
&lt;br /&gt;
monitor  mnbb{&lt;br /&gt;
	conditon oktowrite, oktoread;&lt;br /&gt;
	queue qwrite,qread;&lt;br /&gt;
&lt;br /&gt;
	procedure entry write(int n, struct elem *v){&lt;br /&gt;
		if(n &amp;gt; BUFSIZE){&lt;br /&gt;
			return(ERROR);&lt;br /&gt;
		}&lt;br /&gt;
		if( n &amp;gt; (BUFSIZE - buff.lengh)){&lt;br /&gt;
			qwrite.queue( n, 1 );&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		}&lt;br /&gt;
		buff.queue( v, n );&lt;br /&gt;
		if(qread.read() &amp;lt;= buff.lengh){&lt;br /&gt;
			qread.dequeue(1);&lt;br /&gt;
			oktoread.signal();&lt;br /&gt;
		}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
	procedure entry read(int m, struct elem *w){&lt;br /&gt;
		if(m &amp;gt; BUFSIZE){&lt;br /&gt;
			return(ERROR);&lt;br /&gt;
		} &lt;br /&gt;
		if(m &amp;gt; buff.lengh){&lt;br /&gt;
			qread.queue( m, 1 );&lt;br /&gt;
			oktoread.wait();&lt;br /&gt;
		}&lt;br /&gt;
		w = buff.dequeue(m);&lt;br /&gt;
		if(qwrite.read() &amp;lt;= (BUFSIZE - buff.lengh)){&lt;br /&gt;
			qwrite.dequeue(1);&lt;br /&gt;
			oktowirte.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
- Midolo&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 nmbb{&lt;br /&gt;
	queue buffer;&lt;br /&gt;
	condition oktowrite;&lt;br /&gt;
	condition oktoread;&lt;br /&gt;
	&lt;br /&gt;
	/* assumiamo che essendo un buffer limitato ci sia un solo processo che vuole scrivere e un solo processo che vuole leggere */&lt;br /&gt;
	int N, M;&lt;br /&gt;
	&lt;br /&gt;
	procedure entry write(int n, struct elem *v){&lt;br /&gt;
		if(n&amp;gt;BUFSIZE) return;&lt;br /&gt;
		N=n;&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;lt; N)&lt;br /&gt;
			oktowrite.wait();&lt;br /&gt;
		&lt;br /&gt;
		for(i=0; i&amp;lt;N; i++)&lt;br /&gt;
			buffer.enqueue(v[i]);&lt;br /&gt;
			&lt;br /&gt;
		if(M &amp;gt;= buffer.len)&lt;br /&gt;
			oktoread.signal();&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
	procedure entry read(int m, struct elem *w){&lt;br /&gt;
		if(m&amp;gt;BUFSIZE) return;&lt;br /&gt;
		M=m;&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;lt; M)&lt;br /&gt;
			oktoread.wait();&lt;br /&gt;
		&lt;br /&gt;
		for(i=0; i&amp;lt;M; i++)&lt;br /&gt;
			w[i] = buffer.dequeue;&lt;br /&gt;
		&lt;br /&gt;
		if((BUFSIZE - buffer.len) &amp;gt;= N)&lt;br /&gt;
			oktowrite.signal();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Si può verificare deadlock. Esempio: un lettore vuole leggere un tot di elementi, ma quelli presenti non sono sufficienti. Uno scrittore a sua volta non può più scrivere un certo numero di elementi in quanto il buffer è parzialmente occupato. Lo scrittore aspetterà che il lettore legga; il lettore aspetterà invece lo scrittore: deadlock.&lt;br /&gt;
&lt;br /&gt;
Gabriele e Giulia&lt;/div&gt;</summary>
		<author><name>Gab</name></author>
	</entry>
</feed>