读写信号量,读写互斥,可以多读
seg R, W; int read_count=0; void read() { P(R); if(read_count==0) { P(W); } read_count++; V(R); reading... P(R); read_count--; if(read_count==0) { V(W); } V(R); } void write() { P(W); writing... V(W); }