Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program prog;
- var writing:boolean;
- lec,nee:integer;
- mutex:semaphore;
- process LECTOR;
- begin
- repeat
- wait(mutex);
- while (writing=true) or (nee>0) do
- begin
- signal(mutex);
- wait(mutex);
- end;
- lec:=lec+1;
- signal(mutex);
- writeln('LEER RECURSO');
- wait(mutex);
- lec:=lec-1;
- signal(mutex);
- forever;
- end;
- process ESCRITOR;
- begin
- repeat
- wait(mutex);
- nee:=nee+1;
- while (writing=true) or (lec>0) do
- begin
- signal(mutex);
- wait(mutex);
- end;
- writing:=true;
- nee:=nee-1;
- signal(mutex);
- writeln('ESCRIBIR EN EL RECURSO');
- wait(mutex);
- writing:=false;
- signal(mutex);
- forever;
- end;
- begin
- initial(mutex,1);
- writing:=false;
- lec:=0;
- nee:=0;
- cobegin
- LECTOR;
- ESCRITOR;
- coend;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement