Locks

Locks

Post by Venkatesh Prasad Ranganat » Thu, 23 Jan 2003 23:51:15



Hi,

What is the difference between read_lock_bh(), read_lock_irq(), and
read_lock() as available in spinlock.h?

--

Venkatesh Prasad Ranganath,
Dept. Computing and Information Science,
Kansas State University, US.
web: http://www.cis.ksu.edu/~rvprasad

 
 
 

Locks

Post by Kasper Dupon » Fri, 24 Jan 2003 01:26:09



> Hi,

> What is the difference between read_lock_bh(), read_lock_irq(), and
> read_lock() as available in spinlock.h?

The first two will disable bottom-halves or interrupts while holding
the lock. That is necesarry for locks that are used in processes as
well as bottom-halves or interrupts.

Take a look on linux/Documentation/spinlocks.txt for more info.

--
Kasper Dupont -- der bruger for meget tid p? usenet.

for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

 
 
 

Locks

Post by Andi Klee » Fri, 24 Jan 2003 01:28:01



Quote:> What is the difference between read_lock_bh(), read_lock_irq(), and
> read_lock() as available in spinlock.h?

They all take a rw spin lock for reading.

read_lock doesn't protect you again interrupts. You have to make sure
no interrupt will try to grab the same lock.

read_lock_bh works as read_lock, but also protects you against software
interrupts and tasklets.

read_lock_irq works as read_lock, but also protects you against hardware
interrupts and software interrupts too. This is needed if the interrupts
can access the same lock, otherwise you risk dead lock. One trap is that
its release function (read_unlock_irq) will unconditionally turn on interrupts
again. If you turned them off previously this may be not intended.

So the recommended function to use instead of read_lock_irq is
read_lock_irqsave, which saves the old interrupt enabled flag.

-Andi

 
 
 

1. netscape rpm from compaq + my box = lock lock lock

  I've been having some wierd lockups with the netscape rpm that compaq
released for linux alpha. I'm running a pc164 with two tulip cards in it,
with pppoe. Every once in awhile, I'll crank up netscape and look at a
site only to have my machine lock up amazingly tight. Has anyone seen this
before?

--
---
Eric Jones                    

  If you can't figure out what to remove in the above addy to email me, then
you are a cephalopod.
  Here's a few email addresses to help out the spammers:        

IS YOUR INTERNET BROKED? DOES EMAILING THE NETSCAPE SYSOP NOT FIX IT?

2. IE Hopelessly bug ridden

3. Modem TX and RX status via Num Lock-Caps Lock-Scroll Lock

4. .bashrc not being sourced by xterms

5. unable to lock mailbox: no locks available

6. execute a static linked elf

7. More mail file locking questions (lockf, NFS, /var/spool/mail/*.lock)

8. 2 man pages needed (SCO SYS5 R3.4.2)

9. Locking mechanisms / fcntl.c locks.c

10. XScreenSaver lock -> lock console

11. Locked files - who has it locked?

12. Problem with getty leaving locks in /etc/locks

13. caps lock -> fn lock modification possible?