Re: A new Critical Section for high contention situations
- From: "Remy Lebeau" <no.spam@xxxxxxxxxxx>
- Date: Thu, 15 May 2008 23:28:25 -0700
"Kürsat" <xx@xxxxxx> wrote in message
news:O3NzUVrtIHA.3716@xxxxxxxxxxxxxxxxxxxxxxx
Oh my God! I am so sorry, using "if" in place of "while" makes
almost every code illogical. I am sorry again, below is updated code:
Your code is still missing an important feature that every synchronization
object MUST support. If a thread calls enter() and then calls enter() again
before calling leave() (such as from nested code making local calls to
enter/leave()), enter() MUST EXIT WITHOUT BLOCKING, and the lock must NOT be
released until leave() is called TWICE. Otherwise a deadlock occurs. Your
code is not handling those possibilities yet. The first time enter() is
called, your lock is NOT_OWNED, so it gets updated to OWNED and enter()
exits. However, the next time enter() is called on the same thread, the
lock may still be OWNED, and you would then enter an endless loop since the
owning thread can never call leave(). The only possibility would be if
another thread called leave(), but that would be impossible since enter()
could never exit in those threads, either.
Gambit
.
- Follow-Ups:
- References:
- A new Critical Section for high contention situations
- From: Kürşat
- Re: A new Critical Section for high contention situations
- From: Keith Moore
- Re: A new Critical Section for high contention situations
- From: Kürsat
- Re: A new Critical Section for high contention situations
- From: Scott McPhillips [MVP]
- Re: A new Critical Section for high contention situations
- From: Kürsat
- A new Critical Section for high contention situations
- Prev by Date: Re: A new Critical Section for high contention situations
- Next by Date: Re: Launch an executable as a user from an administrative account
- Previous by thread: Re: A new Critical Section for high contention situations
- Next by thread: Re: A new Critical Section for high contention situations
- Index(es):
Relevant Pages
|