<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6249.1">
<TITLE>[plt-scheme] Re: Shared resources for servlets</TITLE>
</HEAD>
<BODY dir=ltr>
<DIV>I'm not sure that would work.</DIV>
<DIV>Consider this:</DIV>
<DIV>3 readers are reading. A writer comes and blocks. Then a reader comes and
joins in, blocking the writer even longer. This could block indefinitely, which
won't be very good, would it?</DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV><FONT size=2>-----Original Message----- <BR><B>From:</B> Keith Frost
[mailto:keithf@amnis.com] <BR><B>Sent:</B> ג 09/09/2003 18:31 <BR><B>To:</B>
plt-scheme@list.cs.brown.edu <BR><B>Cc:</B> <BR><B>Subject:</B> [plt-scheme]
Re: Shared resources for servlets<BR><BR></FONT></DIV>
<P><FONT size=2> For list-related administrative tasks:<BR> <A
href="http://list.cs.brown.edu/mailman/listinfo/plt-scheme">http://list.cs.brown.edu/mailman/listinfo/plt-scheme</A><BR><BR>If
I'm not mistaken, you've answered your own question: just use
a<BR>module.<BR>When subsequent servlets 'require' the same module, it is not
reloaded, and<BR>any local state in the module is preserved. If you need
to serialize<BR>access to<BR>resources controlled by the module, you can
create a semaphore to do so<BR>(see 'MzScheme Language Manual: Section 7.4'),
so that servlets may block<BR>while waiting for the resource to become
available.<BR><BR>Which brings to mind a question I've had in the back of my
mind, and I<BR>expect someone<BR>on this list could help me with.
Consider the common resource model<BR>"One writer -- many readers". In
other words, if a reader goes to<BR>access the resource,<BR>it needs only
check whether there is a writer accessing it. If so, it<BR>blocks until
the<BR>writer releases it. If not, it may go ahead, so that any number
of<BR>readers can be<BR>simultaneously accessing the resource (a database, or
even a file,<BR>say). If a writer<BR>goes to access the resource, it has
to check if there is another writer,<BR>or any readers,<BR>currently accessing
it. If so, it blocks until all readers and any<BR>writer have released
it.<BR><BR>What is the simplest, or a recommended, way to achieve this
resource<BR>pattern using<BR>MzScheme's threads and
semaphores?<BR><BR><BR><BR>/ /<BR><BR><BR></FONT></P></BLOCKQUOTE>
</BODY>
</HTML>