NetLogo User Community Models
(back to the NetLogo User Community Models)
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".
Try It in NetLogo Web
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
SECOND TYPE OF R/W PROBLEM - writers-preference:
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, an unlimited number of readers can access the document
- if there is a writer waiting in the queue, he will be the next to access the document when available
The main rule of this model is that no writer in the queue, shall be kept waiting longer than absolutely necessary.
HOW TO USE IT
- 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")
- Readers - how many readers are actually in the system?
- Writers - how many writers 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.
- 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
From the number of writers in the system (unprocessed writers) you can see that in the second readers-writers problem the readers are starving.
THINGS TO TRY
Try moving the sliders. For example, if you set the "probability-writer-comes" to a very low value and "probability-writer-leaves" to a very high value, the readers won't starve.