NetLogo banner

Home
Download
Help
Resources
Extensions
FAQ
NetLogo Publications
Contact Us
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

  Donate

NetLogo User Community Models

(back to the NetLogo User Community Models)

[screen shot]

Download
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".(The run link is disabled for this model because it was made in a version prior to NetLogo 6.0, which NetLogo Web requires.)

WHAT IS IT?

The problem of Readers and Writers describes a computing problem with concurrency. This problem was described for the first time by P. J. Courtois et al. in their work from 1971.

Suppose we have a shared document. There are two types of agents in this model - readers, who access the document only for reading and writers, who access the document for modification. The problem is with the agents accessing this document at the same time

HOW IT WORKS

THIRD TYPE OF R/W PROBLEM - no-preference:
In the first readers-writers problem, the writers are starving while in the second readers-writers problem, readers starve.
There are several rules in this model:
- only one type of agent can access the document at the same time
- only one writer can modify the document
- if the document is locked for reading (writing), it doesn't mean that more readers (writers) can access the document
- there is certain amount of time when the document is locked either for writing or reading

The main rule of this model is that neither writers nor readers shall be allowed to starve.

HOW TO USE IT

Initial settings:
- probability-reader-comes: Interval (0-100) - what is the probability that the next agent,
who wants to access the document will be a reader?
- probability-reader-leaves: Interval (0-100) - probability, that the reader will finish his action ("how long he reads").
- probability-writer-comes: Interval (0-100) - what is the probability that the next agent,
who wants to access the document will be a writer?
- probability-writer-leaves: Interval (0-100) - probability, that the writer will finish his action ("how long he writes").
- steps_reading_writing: Interval (1-10) - how long (how many steps) is the document opened for either reading or writing?
- reader_writer_first: chooser - which type of agent will come first to the system for the very first step?

Plots:
- Readers - how many readers are actually in the system?
- Writers - how many readers are actually in the system?
- Total readers - total number of processed readers plus number of readers currently in the system.
- Total writers - total number of processed writers plus number of writers currently in the system.
- Allow Readers - if >0 then the document is opened for reading, no writers allowed. As well shows the number of steps remaining for reading.
- Allow Writers - if >0 then the document is opened for writing, no readers allowed. As well shows the number of steps remaining for writing.
- Actual number of readers-writers: chart showing number of agents in the system.
- Number of readers-writers: chart showing number of agents in the system
and total number of processed agents.

THINGS TO NOTICE

You can see that even when the document is opened for writing, no writers can be allowed to access the document.
This happens when there are still some readers who haven't finish their reading yet. Sometimes this requires readers to wait even though the document is opened for reading.

THINGS TO TRY

Try moving the sliders.

(back to the NetLogo User Community Models)