Amazon Interview Question
Software Engineer / DevelopersCountry: India
readCount=0;
mutex=0;
Reading:
while(writelock == true);
writelock=true;
while(mutex==1);
mutex=1;
readCount++;
mutex=0;
---------
READ
---------
while(mutex==1);
mutex=1;
readCount--;
mutex=0;
writelock=false;
Writing:
while(readLock >0 && writelock==true)
{
writelock=true;
---------
WRITE
---------
writelock=false;
}
do we need to do anything here when it is only the read operations.
- DashDash April 21, 2013