Re: Inserting single semaphore into the JavaSpace

Oliver Plohmann <[email protected]> Fri, 17 Oct 2008 15:27:28 +0200
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Hello,

thanks for the link. The article explains the idea of a token used as a=20
semaphore. This is what I saw in Freeman's book and that's how I intend=20
to do synchronization. Problem is that someone must be the first one to=20
insert the >single< semaphore entry into the space since it is empty to=20
begin with. Now there might be several clients using the space and there=20
must be one of them who will insert the initial semaphore. How do they=20
agree on who will do this when an initial semaphore not yet exists in=20
the space to prevent race conditions from happening when working out the=20
agreement who will be the one?

As explained I use the RMI registry as a workaround to determine who is=20
the first one (everyone that comes second faces a AlreadyExistsException=20
when binding a remote object to the registry that already exists there=20
with the same name) and thus is allowed to write the initial semaphore=20
to the space.

I feel a method like

writeOnce(Entry entry, Transaction trx, long timeout) throws=20
EntryAlreadyExistsException

would be a nice thing to have in the JavaSpace interface. Many=20
concurrency issues could be solved easily this way and efficiently.=20
Maybe there is still someone who has had this problem as well and found=20
a simple quick solution.

Thanks, Oliver Plohmann

Holger Hoffst=E4tte wrote:
> Oliver Plohmann wrote:
>  =20
>> I need to have for certain operations exclusive access to the JavaSpac=
e
>> or at least part of it. [..]
>>    =20
>
> There is a "discussion" with a pointer to an article on TSS:
> http://www.theserverside.com/common/printthread.tss?thread_id=3D45418
>
> This should do what you want.
>
> -h
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
> To unsubscribe, send email to [email protected] and include in the =
body
> of the message "signoff JAVASPACES-USERS".  For general help, send emai=
l to
> [email protected] and include in the body of the message "help".
>
> To view past JAVASPACES-USERS postings, please see:
> http://archives.java.sun.com/archives/javaspaces-users.html
>
>  =20

--=20

www.objectscape.org

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
To unsubscribe, send email to [email protected] and include in the bo=
dy
of the message "signoff JAVASPACES-USERS".  For general help, send email =
to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html