Prova Teorica 2013.06.21

From Sistemi Operativi
Revision as of 17:13, 28 May 2014 by Save (talk | contribs)
Jump to navigation Jump to search

Testo del compito

Esercizio c.1

monitor nvie
{
	condition oktoread;
	queue buffer[N]; 
 
 
	procedure entry put(int n, generic object)
	{
		
                           if (buffer[n].length < NELEM)
				buffer[n].enqueue(object);
 
		           oktoread.signal();
 
	}
 
	procedure entry generic get(generic *object)
	{

               int count=0;

			for (int i=0;i<N;i++)
                        {   
                            if (buffer[i].length>0)
                                  count++;
                            return None ;
                        }
			for (int j=0;j<N;j++)
                        {   if (count>=N/2)
                                (buffer[j].dequeue(*object) ;
                            oktoread.wait();
                        }
       }
}

Save



Esercizio g.1

[soluzione]

Esercizio c.2

#Casi possibili delle iterazioni
int val = 0

PQPQQ (((val +1) *2) +1) * 2 * 2	 	12
PQQPQ (( val +1 ) * 2 * 2) +1 * 2		12
QQPQP (((val * 2 * 2) + 1 )* 2) + 1		3
QPQQP (((val * 2) + 1) * 2 * 2) + 1		5
QPQPQ ((((val * 2) + 1) * 2) + 1) * 2		6

a) 	#Quindi i valori possibili sono  (3, 5, 6, 12)
b)	#

- Midolo e Marangoni