Re: A new Critical Section for high contention situations
- From: "Kürşat" <xx@xxxxxx>
- Date: Fri, 16 May 2008 09:58:53 +0300
Yes, you are right. I implemented the class for a certain problem. I need to
protect a queue which is pounded by a number of threads. To synchorinize
enqueus and dequeues I used CRITICAL_SECTION but because of high contention
kernel transition was high and performance was low. Anyway, your warning is
very important for all general purpose implementations.
"Remy Lebeau" <no.spam@xxxxxxxxxxx> wrote in message
news:OLlA73xtIHA.4560@xxxxxxxxxxxxxxxxxxxxxxx
"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
.
- 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
- Re: A new Critical Section for high contention situations
- From: Remy Lebeau
- A new Critical Section for high contention situations
- Prev by Date: Re: A new Critical Section for high contention situations
- Next by Date: Re: A new Critical Section for high contention situations
- 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
|