15.06.2013 Views

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

Dispensa in PDF - Dipartimento di Scienze Ambientali, Informatica e ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Macch<strong>in</strong>a 1 Macch<strong>in</strong>a 2<br />

browser richiesta Web<br />

server<br />

Carnielli Efrem: Programmazione a componenti<br />

richiesta<br />

responso responso<br />

Figura 1.4. Interazione tra processi <strong>in</strong> ambiente s<strong>in</strong>gle-thread<br />

Programmazione a componenti<br />

DB server<br />

Il problema è chiaro, il web server non può rispondere al browser f<strong>in</strong>chè il DB<br />

server non risponde.<br />

Ma cosa avviene esattamente? Ve<strong>di</strong>amo <strong>in</strong> figura 1.5 una rappresentazione degli<br />

stati dei processi.<br />

Il processo relativo al web server è nello stato <strong>di</strong> runn<strong>in</strong>g, una volta che <strong>in</strong>oltra la<br />

richiesta al DB server deve attendere che quest’ultimo risponda, lo scheduler si<br />

preoccupa <strong>di</strong> metterlo <strong>in</strong> wait e per fare ciò è necessario salvare <strong>in</strong> memoria<br />

centrale lo stato <strong>di</strong> esecuzione del processo che viene bloccato. Queste <strong>in</strong>formazioni<br />

vengono memorizzate proprio nel PCB del processo, e sarà sempre dal PCB che<br />

esse verranno lette quando si dovrà proseguire l'esecuzione; la risorsa processore<br />

viene liberata e sempre lo scheduler si preoccupa <strong>di</strong> assegnarla al DB server che<br />

deve rispondere. Avviene qu<strong>in</strong><strong>di</strong> un contest switch che si ripete non appena il DB<br />

server avrà confezionato ed <strong>in</strong>viato la risposta al web server.<br />

Supponiamo qu<strong>in</strong><strong>di</strong> che il web server sia il processo che si mette <strong>in</strong> wait<strong>in</strong>g dopo<br />

ogni richiesta del browser per aspettare l’evento “responso del web server”; se<br />

arrivassero 1000 avrei una commutazione <strong>di</strong> contesto cont<strong>in</strong>ua solo per risolvere<br />

richieste magari esigue.<br />

Il proce<strong>di</strong>mento è notevolmente costoso.<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!