commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Zeigermann <oliver.zeigerm...@gmail.com>
Subject Re: [transaction.locking]Want to lock intervals
Date Tue, 05 Apr 2005 09:37:59 GMT
Not quite sure if this will work, but you could store all intervals
there currently is a lock on in a resource manager. As soon as the
lock is freed, the intervals gets removed and to every interval a lock
is associated.

When a lock on an interval is tried you first will have ot check for
all other intersecting ones without actually acquiring locks on them.
Only if this works you can acquire the lock on the desired interval.
Otherwise you will wait for them to be freed.

All this would be in the lock manager and would not require changes to
the lock classes.

Does this make sense?

Oliver


On Apr 5, 2005 11:24 AM, Melanie.Bats@UTBM.fr <Melanie.Bats@utbm.fr> wrote:
> Hi,
> 
> Selon Oliver Zeigermann <oliver.zeigermann@gmail.com>:
> > I suppose you pass the interval as the resourceId, right?
> 
> Yes exactly.
> 
> > The problem is that normally a single locks gets assigned to a resourceid. I
> > do not think there is an easy solution if  your intervals are not
> > discrete.
> 
> They are not discrete. There is infinity number of values inside an interval ;(
> 
> > But if they are you could just enumerate all values as
> > resourceIds and try to lock check each and every of them. This would
> > of course require writing your own lock manager,  but that shouldn't
> > be too hard.
> 
> To find if intervals intersect I use the functions of the package
> xxl.core.util.Interval1D. If intervals intersect I must wait that thread release
> locks on the interval. Using this I don't need to test all the values.
> 
> Do you have ideas ? Is it possible to implement this just by modifying the
> ReadWriteLockManager ?
> 
> Thanks,
> Mel
> 
> > On Apr 5, 2005 10:46 AM, Melanie.Bats@UTBM.fr <Melanie.Bats@utbm.fr> wrote:
> > > Hi,
> > >
> > > I want to use the ReadWriteLockManager and ReadWriteLock on interval. To
> > > facilitate the operation on interval I use the package
> > xxl.core.util.Interval1D.
> > >
> > > The LockManager works well if I try to get and release locks on same
> > interval.
> > > For example, a first thread T1 get a ReadLock on the interval I[1, 122] and
> > then
> > > a second thread T2 try to obtain a WriteLock on I, T2 will wait until T1
> > release
> > > its lock on I.
> > >
> > > The LockManager does not work well in this case : a first thread T1 get a
> > > ReadLock on the interval I1[1 , 5] and then a second thread T2 try to
> > obtain a
> > > WriteLock on I2[4 , 7], T2 will obtain is lock and we will have
> > incompatible
> > > locks on the intersection of I1 and I2 [4, 5].
> > >
> > > The problem is that I1 and I2 are two different objects for the
> > LockManager.
> > >
> > > Is that possible to modify the ReadWriteLock and the ReadWriteLockManager,
> > in
> > > order to determine when intervals intersect. It must verify the
> > compatibility of
> > > the lock or wait for the release when it is incompatible ?
> > >
> > > I expect I am clear, if not ask me for details :o)
> > >
> > > Thanks for your help,
> > >
> > > Mel
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message