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 }
读写进程同步问题
最新推荐文章于 2024-08-03 17:18:45 发布