Here is the code for the reader process (workable code)
reader(){
while(true){
P(mutex);
readerCounter++;
if((readerCount == 1)
P(OKtoaccessDB);
V(mutex);
accessDB;
readerCounter--;
if(readerCounter == 0)
V(OKtoaccessDB);
V(mutex);
}
}
And here is the process for writer;
writer(){
while(true){
P(OKtoacessDB);
accessDB;
V(OKtoacessDB);
}
}
What would be the outcome if replacing (in reader)
From:
if(readerCounter == 0)
V(OKtoacessDB);
V(mutex);
to :
if(readerCounter == 0){
V(OKtoaccessDB);
V(mutex);
}
Thank you!