Re: Another locking question.

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Richard Blewett (richard_at_dotnetconsult.co.uk)
Date: 09/12/04


Date: Sun, 12 Sep 2004 09:50:14 +0100


>From testing this out a while back:

if the other threads are of equal priority they appear to aquire the lock in
teh order they requested it (I haven't see this *documented* anywhere so I
wouldn't base my system on this behavior).

If Thread 3 has a higher priority than Thread 2 it will acquire the lock
first (at least this was the behavior I observed) irrespective of the order
the two threads attempted to acquire the lock - which is how it should be

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richard/weblog

"Morten Wennevik" <MortenWennevik@hotmail.com> wrote in message
news:opsd6dc6jaklbvpo@stone...
> Hi Cool Guy,
>
> I'm not entirely certain of this, but I think you have no way of knowing
> which of the waiting threads aquires the lock after it is released.
> Thread 2 and thread 3 have equal priority in aquiring the lock, and thread
> 3 might get the lock before thread 2.
>
> --
> Happy coding!
> Morten Wennevik [C# MVP]



Relevant Pages

  • Re: Vector (was Re: Change character in string)
    ... already has it's first fork when .equalsis invoked ... so it's too late for grabbing the napkin now. ... each method would have to aquire Collections.synchronizedCollection's ... central lock - and that has a hidden price tag that may really hurt. ...
    (comp.lang.java.programmer)
  • wacom + runtime PM = AA deadlock
    ... by mistake when runtime PM is enabled by default for input devices, ... hangs on wacom open: ... turn calls wacom_resume which tries to aquire the lock again. ...
    (Linux-Kernel)
  • Re: Semaphores and .NET
    ... > mutex and shared file to hold the count or mem mapped file, ... To aquire a lock on the semaphore, you need to obtain syncLock (which is ... available, you block at the Monitor.Waitcall, INSIDE the lock statement. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [PATCH] LIB: remove unmatched write_lock() in gen_pool_destroy
    ... significant code change. ... Its dumb to aquire the lock you're gonna free anyway. ... Maybe some BUG_ONthat sez nobody better be holding this lock? ...
    (Linux-Kernel)
  • Re: [PATCH] LIB: remove unmatched write_lock() in gen_pool_destroy
    ... significant code change. ... Its dumb to aquire the lock you're gonna free anyway. ... Maybe some BUG_ONthat sez nobody better be holding this lock? ...
    (Linux-Kernel)