Re: When KeEnterCriticalRegion ?

From: dave (dave_at_discussions.microsoft.com)
Date: 09/04/04


Date: Fri, 3 Sep 2004 17:15:01 -0700


 
 I need to implement this flow:

      Appl_1< r/w > Drv_1 < r/w > Drv_2 < r/w > Appl_2
 
Where:
    Drv_1 & Drv_2 communicate through chared memory.
 
 And I'm looking for the right way
 to synchronize access to the shared data.
 Right now I'm using spin lock but I'm not sure
 if it's the only way.
 
 Probably I will read ch.4/5 one more time.

 Thank you
   

"Walter Oney" wrote:

> dave wrote:
> >
> > "Highest-level drivers can call this routine
> > while running in the context of the tread
> > that requested the current I/O operation..."
>
> This is what happens when tech writers who have too little understanding
> interview developers who have too little time. AFAIK,
> KeEnterCriticalRegion does exactly one thing: it prevents delivery of
> certain APC's to a thread while leaving the thread at PASSIVE_LEVEL. The
> reason for using it is so that you can enter a critical section (by
> claiming a mutex or a SynchronizationEvent, for example) and know that
> your code won't be reentered due to an APC getting queued for the same
> thread. File system drivers care about this, but most other drivers
> don't. That's because most other drivers either can't be reentered on an
> APC path or synchronize at DISPATCH_LEVEL using a spin lock.
>
> So what has led you down this particular rathole?
>
> --
> Walter Oney, Consulting and Training
> Basic and Advanced Driver Programming Seminars
> Check out our schedule at http://www.oneysoft.com
>



Relevant Pages

  • Re: PATCH: switch ide-proc to use the ide_key functionality
    ... drivers_lock is the spin lock you must own to update the drivers list ... unless we take ide_cfg_sem at the top of the proc code before setting_sem. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: [PATCH] synchronize_irq needs a barrier
    ... (that is, to synchronize anything at all), it needs a barrier or you are ... just making a decision based on a totally random value of desc->status ... some drivers like tg3 actually do an smp_mbbefore calling ...
    (Linux-Kernel)
  • [PATCH 00/10] usb-serial: Switches from spin lock to atomic_t.
    ... As showed by Eduardo Habkost some days ago, the spin lock 'lock' in the ... struct 'usb_serial_port' is being used by some USB serial drivers to protect ... the access to the 'write_urb_busy' member of the same struct. ... The following patch series does that. ...
    (Linux-Kernel)