Re: A new Critical Section for high contention situations



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




.



Relevant Pages

  • Re: Requiring a password?
    ... Teach your users to lock ... >> their workstations if they don't want their mail read. ... >>> application running on the desktop then only the Outlook app will ... >>> exit and leave the session connected to the mailbox. ...
    (microsoft.public.exchange.admin)
  • Re: Ensuring a nice clean application quit experience
    ... My preferred design is to have a table with a single row that contains ... the network name of the person currently connected to the database. ... there is no 100% reliable way to delete the record on exit. ... The record lock should release when Access shuts down. ...
    (comp.databases.ms-access)
  • Re: A new Critical Section for high contention situations
    ... object MUST support. ... enter/leave), enterMUST EXIT WITHOUT BLOCKING, and the lock must NOT be ... The first time enteris ... could never exit in those threads, ...
    (microsoft.public.win32.programmer.kernel)
  • [RFC 9/13] Char: nozomi, lock cleanup
    ... - don't lock interruptible in close or the card might not be stopped on last ... if (!port ||!dc) ... goto exit; ... must test lock as tty layer wraps calls ...
    (Linux-Kernel)
  • Re: yumex
    ... > to either lock down or exit. ... any corrections or suggestions to this? ... > other than that its a top notch program.. ...
    (Fedora)