1. Facultad de Ciencias Humanas
y de la Educación
Carrera de Docencia en Informática
LECTORES Y ESCRITORES
Nombre: María del Cisne Loján
Silvia Chango
Lusy Chisag
Tutor: Ing.Javier Sánchez
Semestre: Séptimo
Septiembre 2011- Febrero 2012
2. FUNCIÓN MAIN
Crea un Su proceso
proceso padre hijo los
Lectores
Escritores
3. Base de datos
Lector Escritor
Varios lectores
Pueden acceder
registro Solo uno escribir
simultáneamente
4. Cómo resolver
el problema
Identificar
estado Se debe Identifica
contar a
compartido y Condiciones
los
restringido lectores de espera y
señalización
Lector Lector
Escritor Escritor
escritor escritor
No admite otro Cuando termine
No se accede Si existe BD debe debe señalizar el
escritor ni
base de datos lector esperar que esta
esperando
8. procedure open(isReader:Boolean); procedure close(isReader:
begin Boolean);
if isReader then begin begin
if activeW or not empty(okeyWrite) if isReader then begin
then delay(okeyRead); readCount:=readCount-1;
readCount:=readCount+1; if (readCount=0)
resume(okeyRead) then resume(okeyWrite);
end else begin -- is writer end else begin
if activeW or (readCount<>0) activeW:=False;
then delay(okeyWrite); if not empty(okeyRead)
activeW:=True; then resume(okeyRead);
end; else resume(okeyWrite);
end;
9. program AlarmClock;
const NUM_SLEEPER=3;
monitor alarm; ...
monitor screen ...
process driver ...
process type SleeperType ...
var sleepers: array [1..NUM_SLEEPER] of SleeperType;
i:Integer
begin
cobegin driver; for i:=1 to NUM_SLEEPER do sleepers[i](i); coend;
end;