Re: spinlock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Frank.

Dne petek 28. februar 2003 20:44 je Frank A. Uepping napisal(a):

> For clarification.

/usr/src/linux/Documentation/spinlock.txt contains AFAIK a great description 
of spinlocks.

> When I have a struct that I access from proc and int context I have
> to use the _irqsave() variant in the proc context (in order to prevent
> an irq to be happen) but in the int context I stick to the common variant.

Ehmmm... this can be read a bit missleadingly. Let me try to state it better:

1. Structures accessed from all contexts:
(use this if unsure what to do -- this is the safest way of mutex, but no 
schedule() is allowed !!)
        spin_lock_irqsave(&xxx_lock, flags);
        ... critical section here ..
        spin_unlock_irqrestore(&xxx_lock, flags);

2. Structures accessed from user context only:
	One should use mutexes here anyway :P
        spin_lock(&lock);
        ...
        spin_unlock(&lock);

3. There are also read/write spinlocks that optimise a case of multiple 
readers and few writers. But I won't go into these.
	read /usr/src/linux/Documentation/spinlock.txt for details :-).

> Further a spinlock in not allowed to hold while the current proc sleeps.
> Semaphores are not allowed to use in int context because they might
> sleep/block.

:-).

-- 
best regards,
Rok Papež.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux