Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/include/linux/semaphore.h

  1 /*
  2  * Copyright (c) 2008 Intel Corporation
  3  * Author: Matthew Wilcox <willy@linux.intel.com>
  4  *
  5  * Distributed under the terms of the GNU GPL, version 2
  6  *
  7  * Please see kernel/semaphore.c for documentation of these functions
  8  */
  9 #ifndef __LINUX_SEMAPHORE_H
 10 #define __LINUX_SEMAPHORE_H
 11 
 12 #include <linux/list.h>
 13 #include <linux/spinlock.h>
 14 
 15 /* Please don't access any members of this structure directly */
 16 struct semaphore {
 17         raw_spinlock_t          lock;
 18         unsigned int            count;
 19         struct list_head        wait_list;
 20 };
 21 
 22 #define __SEMAPHORE_INITIALIZER(name, n)                                \
 23 {                                                                       \
 24         .lock           = __RAW_SPIN_LOCK_UNLOCKED((name).lock),        \
 25         .count          = n,                                            \
 26         .wait_list      = LIST_HEAD_INIT((name).wait_list),             \
 27 }
 28 
 29 #define DEFINE_SEMAPHORE(name)  \
 30         struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
 31 
 32 static inline void sema_init(struct semaphore *sem, int val)
 33 {
 34         static struct lock_class_key __key;
 35         *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val);
 36         lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0);
 37 }
 38 
 39 extern void down(struct semaphore *sem);
 40 extern int __must_check down_interruptible(struct semaphore *sem);
 41 extern int __must_check down_killable(struct semaphore *sem);
 42 extern int __must_check down_trylock(struct semaphore *sem);
 43 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
 44 extern void up(struct semaphore *sem);
 45 
 46 #endif /* __LINUX_SEMAPHORE_H */
 47 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us