读写进程同步问题

来源:互联网 发布:交朋友软件哪个好 编辑:程序博客网 时间:2024/06/06 02:27
void reader(){   while(1){      wait(x);        readcount++;        if (readcount==1)              wait(wsem);      signal(x);      doReading();      wait(x);        readcount--;        if (readcount==0)             signal(wsem);      signal(x);   }}
Writer()
{  while (TRUE) {                     // loop forever     create_data();                         // create data to enter into database (non-critical)     down(&db);                             // gain access to the database     write_db();                            // write information to the database     up(&db);                               // release exclusive access to the database}

0 0
原创粉丝点击