SO-mod 3-Procesos - Facultad de Ingeniería - Universidad Nacional ...
SO-mod 3-Procesos - Facultad de Ingeniería - Universidad Nacional ...
SO-mod 3-Procesos - Facultad de Ingeniería - Universidad Nacional ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Buffer limitado – Solución con memoria compartida<br />
Datos compartidos<br />
#<strong>de</strong>fine BUFFER_SIZE 10<br />
type<strong>de</strong>f struct {<br />
. . .<br />
} item;<br />
item buffer[BUFFER_SIZE];<br />
int in = 0;<br />
int out = 0;<br />
JRA © 2008<br />
Sistemas Operativos – <strong>Procesos</strong><br />
Buffer limitado (cont.)<br />
<br />
Proceso Consumidor<br />
repeat<br />
while in = out do no-op;<br />
nextc := buffer [out];<br />
out := out+1 <strong>mod</strong> n;<br />
…<br />
consume un item en nextc<br />
…<br />
until false;<br />
<br />
La solución es correcta, pero solo pue<strong>de</strong> llenar el buffer hasta n–1.<br />
JRA © 2008 Sistemas Operativos – <strong>Procesos</strong><br />
32