Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int r = 0;
- int w = 0;
- read_lock(void)
- {
- r++;
- while( w != 0);
- }
- read_unlock(void)
- {
- r—;
- }
- write_lock(void)
- {
- while( (r != 0) &&
- ( w != 0))
- w++;
- }
- write_unlock(void)
- {
- w--;
- }
- read_lock()
- // Critical Section
- read_unlock();
- write_lock()
- // Critical Section
- write_unlock();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement