Creato da pastuweb.com
Share My Page
My Social Accounts
Account FaceBook Account LinkedIn Account Twitter Account Google Plus Account Git Hub

It 'a similar problem to the producer / consumer only in this casethat the consumer reads the data but does not clear. Write operations must be done in mutual exclusion and reads well in competition but not during write operations.

Readers and writers in JAVA
With the classes of the problem Readers / writers could be resolved as follows:


void start_read(void) {
nr++;
await(nw==0);
}

void start write(void) {
await (!busy&&nr==0);
nw++;
busy=TRUE;
}

void end_read(void) {
nr--;
}

void end_write(void) {
busy = FALSE;
nw--;
}

void init(void) {
busy=FALSE
nr+nw=0;
}

Average (1 Vote)
The average rating is 5.0 stars out of 5.