empty()
, wait()
, and signal()
and variants
wait()
monitor int count = 0 // invariant: 0 <= count <= 1 cond nonzero // condition: count = 1 void up() count = 1 positive.signal() void down() if count != 1, positive.wait() count = 0
if
may need to be while
depending on release behavior
monitor rw_access bool db_empty = true cond empty_db enter() if !db_empty, empty_db.wait() db_empty = false exit() db_empty = true empty_db.signal()
pure mutual exclusion (no concurrency)
fifo release gives fairness and timeliness
used in a before and after pattern
rw_access.enter() // work the database rw_access.exit()
differentiate readers and writers for database state
monitor rw_access bool writer_in_db = true int readers_in_db = 0 cond clear_db reader_enter() while writer_in_db clear_db.wait() readers_in_db++ reader_exit() readers_in_db-- clear_db.signal_all() writer_enter() while writer_in_db and readers_in_db > 0 clear_db.wait() writer_in_db = true writer_exit() writer_in_db = false clear_db.signal_all()
how does release-all work?
This page last modified on 15 August 2002.