LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Kernel Programming Question.

[ILUG] Kernel Programming Question.

Kenn Humborg kenn at bluetree.ie
Thu May 11 13:03:45 IST 2000


> After succesfully hanging my machine several dozen time at this 
> stage I've a
> question. I'm playing with a PCI Development board at the moment, 
> and for the
> board I maintain "board" struct which I pass around a pointer to  in the
> file->private_data pointer thus maintaining state information.  I 
> have several
> buffers and variables which I will be accessing from bottom_half 
> handlers and
> these can also be accessed from the device driver_write/read 
> functions... what
> is the best way to protect these buffers... 

Add a spinlock field to the board structure and make sure that
every code path that accesses the structure acquires the spin
lock first.

Note that read()/write() (i.e. non-interrupt code) must lock
out interrupts while it holds the spinlock, otherwise deadlocks
can occur.

IIRC, the spin_lock_irqsave and spin_unlock_irqrestore are the
macros that you need.  They will do the spinlock and interrupt
blocking stuff in the correct order.

If you want to get really fancy, you can create spinlocks that 
allow for multiple simultaneous readers but only a single,
exclusive writers.  Look at asm/spinlock.h

Later,
Kenn





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell