Kernel Primitives

From Linux Drivers
(Difference between revisions)
Jump to: navigation, search
(Created page with "== Locking == spin_lock UP UP/PREMPTIBLE SMP include/linux/spinlock.h <pre> #define raw_spin_lock(lock) _raw_spin_lock(lock) static inline void spin_lock(spinlock_t *loc...")
 
(Locking)
Line 1: Line 1:
== Locking ==
+
* [[Kernel Primitives/Locking|Kernel Locking]]
 
+
spin_lock
+
 
+
UP
+
UP/PREMPTIBLE
+
SMP
+
 
+
include/linux/spinlock.h
+
 
+
<pre>
+
#define raw_spin_lock(lock)    _raw_spin_lock(lock)
+
 
+
static inline void spin_lock(spinlock_t *lock)
+
{
+
        raw_spin_lock(&lock->rlock);
+
}
+
</pre>
+
 
+
include/linux/spinilock_api_up.h
+
 
+
<pre>
+
#define __LOCK(lock) \
+
  do { preempt_disable(); __acquire(lock); (void)(lock); } while (0)
+
 
+
#define _raw_spin_lock(lock)                    __LOCK(lock)
+
</pre>
+
 
+
include/linux/spinilock_api_smp.h
+
 
+
<pre>
+
#define raw_spin_unlock(lock)          _raw_spin_unlock(lock)
+
 
+
static inline void spin_unlock(spinlock_t *lock)
+
{
+
        raw_spin_unlock(&lock->rlock);
+
}
+
</pre>
+
 
+
include/linux/spinilock_api_up.h
+
 
+
<pre>
+
#define __UNLOCK(lock) \
+
  do { preempt_enable(); __release(lock); (void)(lock); } while (0)
+
 
+
#define _raw_spin_unlock(lock)                  __UNLOCK(lock)
+
</pre>
+

Revision as of 15:32, 12 March 2012

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox