next up previous
Next: Exclusão Mútua Up: Regiões Críticas Previous: O Par Produtor-Consumidor: Processos

O Par Produtor-Consumidor: Buffer

 
char B[10];
int p=0, c=0, n=0;

int Put(char x) tex2html_wrap_inline710

boolean ok = false;

if(n < 10) tex2html_wrap_inline710

B[p] = x; p = (p+1) % 10; n++; ok = true;

tex2html_wrap_inline714;

return ok;

tex2html_wrap_inline714

int Get(char *x) tex2html_wrap_inline710

boolean ok = false;

if (n > 0) tex2html_wrap_inline710

*x = B[c]; c = (c+1) % 10; n-; ok = true;

tex2html_wrap_inline714;

return ok;

tex2html_wrap_inline714



Osvaldo Sergio F. de Carvalho
Wed Mar 19 14:56:39 EST 1997