Write a C Program readers/writers ?
Solution:
int writers = 0;
int readers = 0;
bool writing = false;
write() {
writers += 1;
await(readers == 0);
await(writing == false);
writing = true;
}
endWrite() {
writing = false;
writers -= 1;
}
read() {
await(writers == 0);
readers += 1;
}
endRead() {
readers -= 1;
}