[plt-scheme] Re: Shared resources for servlets
At Tue, 09 Sep 2003 09:31:23 -0700, Keith Frost wrote:
> Which brings to mind a question I've had in the back of my mind, and
> I expect someone on this list could help me with. Consider the common
> resource model "One writer -- many readers". In other words, if a
> reader goes to access the resource, it needs only check whether there
> is a writer accessing it. If so, it blocks until the writer releases
> it. If not, it may go ahead, so that any number of readers can be
> simultaneously accessing the resource (a database, or even a file,
> say). If a writer goes to access the resource, it has to check if
> there is another writer, or any readers, currently accessing it. If
> so, it blocks until all readers and any writer have released it.
> What is the simplest, or a recommended, way to achieve this resource
> pattern using MzScheme's threads and semaphores?
Whatever you do, don't use sempahores! Use waitables and the operations
on them. There's some description of them in the mzscheme manual, and
you can also find research papers on CML that discuss the same
primitives (althou in the context of a different programming language).
If that's not enough help, perhaps if you can say more about the
resource and how you plan to write to it and I can be more concrete
about how to implement it.
hth,
Robby