Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. procedure reader;
  2. begin
  3.    P(mutex);
  4.    rc := rc + 1;
  5.    if rc = 1 then P(db);
  6.    if(wc>0)
  7.                 licznik = licznik +1;          
  8.    V(mutex);
  9.    read_data_base;
  10.    P(mutex);
  11.    rc := rc - 1;
  12.    if licznik = 5 then V(db);
  13.    licznik = 0;
  14.    V(mutex);
  15.    use_data_read;
  16. end;
  17.  
  18. procedure writer;
  19. begin
  20.    P(mutex);
  21.    wc := wc + 1;
  22.    if wc = 1 then P(db);
  23.    if(rc>0)
  24.                 licznik1 = licznik1+1;         
  25.    V(mutex);
  26.    read_data_base;
  27.    P(mutex);
  28.    wc := wc - 1;
  29.    if licznik1 = 5 then V(db);
  30.    licznik1 = 0;
  31.    V(mutex);
  32.    use_data_read;
  33. end;