{
Wait(i,1,2,"第一个读者");
P(Sdoc);//锁
printf("--------------[%d]----------------缓冲区以被占用\n",i);
Wait(i,1,2,".......取得缓冲区的控制权");
}
V(Scnt);//读锁
V(Sr);//读写锁
Wait(i,2,5,"正在读.........");
Wait(i,1,2,"读完,推出");
P(Scnt);//读锁
g_cntReader--;
if(g_cntReader==0)
{
Wait(i,1 ,2,"最后一个读者");
printf("--------------[%d]----------------缓冲区空闲\n",i);
V(Sdoc);//锁
}
printf("//:%d Readers Left,[%d]is out\n",g_cntReader,i);
V(Scnt);//读锁
if(g_cntReader==0)Wait(i,5,3,"读者全部读完");
1