Upload Code
loading-left
loading loading loading
loading-right

Loading

Profile
No self-introduction
codes (1)
Using semaphore to realize reader writer problem
no vote
In Windows 2000 or Windows XP environment, create a console process, this process contains n threads. Use these n threads to represent n readers or writers. Each thread reads and writes according to the requirements of the corresponding test data file. The semaphore mechanism is used to realize reader priority and writer priority respectively. Read write constraints of reader writer problem (including reader first and writer first) 1) & nbsp; write write mutex: two writers cannot write at the same time 2) & nbsp; read write mutex: one thread cannot read and another thread cannot write at the same time. 3) Read read allow: one or more readers can be reading. Additional restriction of reader priority: if another reader is in the process of reading when applying for reading operation, the reader can directly start reading operation. Additional restriction of writer first: if a reader has another writer waiting to access the shared resource when applying for reading, the reader must wait until there is no writer
yrd1997
2017-12-16
0
1
No more~