Blame view

include/linux/rtmutex.h 3 KB
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  /*
   * RT Mutexes: blocking mutual exclusion locks with PI support
   *
   * started by Ingo Molnar and Thomas Gleixner:
   *
   *  Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
   *  Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
   *
   * This file contains the public data structure and API definitions.
   */
  
  #ifndef __LINUX_RT_MUTEX_H
  #define __LINUX_RT_MUTEX_H
  
  #include <linux/linkage.h>
  #include <linux/plist.h>
  #include <linux/spinlock_types.h>
4f0e056fd   Dave Young   sysctl extern cle...
18
  extern int max_lock_depth; /* for sysctl */
45f8bde0d   Robert P. J. Day   [PATCH] fix vario...
19
  /**
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
20
21
22
23
24
25
26
   * The rt_mutex structure
   *
   * @wait_lock:	spinlock to protect the structure
   * @wait_list:	pilist head to enqueue waiters in priority order
   * @owner:	the mutex owner
   */
  struct rt_mutex {
d209d74d5   Thomas Gleixner   rtmutes: Convert ...
27
  	raw_spinlock_t		wait_lock;
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
28
29
30
31
  	struct plist_head	wait_list;
  	struct task_struct	*owner;
  #ifdef CONFIG_DEBUG_RT_MUTEXES
  	int			save_state;
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
32
33
34
35
36
37
38
39
40
41
  	const char 		*name, *file;
  	int			line;
  	void			*magic;
  #endif
  };
  
  struct rt_mutex_waiter;
  struct hrtimer_sleeper;
  
  #ifdef CONFIG_DEBUG_RT_MUTEXES
e7eebaf6a   Ingo Molnar   [PATCH] pi-futex:...
42
43
44
45
46
47
48
49
50
51
52
53
54
   extern int rt_mutex_debug_check_no_locks_freed(const void *from,
  						unsigned long len);
   extern void rt_mutex_debug_check_no_locks_held(struct task_struct *task);
  #else
   static inline int rt_mutex_debug_check_no_locks_freed(const void *from,
  						       unsigned long len)
   {
  	return 0;
   }
  # define rt_mutex_debug_check_no_locks_held(task)	do { } while (0)
  #endif
  
  #ifdef CONFIG_DEBUG_RT_MUTEXES
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
55
56
  # define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
  	, .name = #mutexname, .file = __FILE__, .line = __LINE__
d5c003b4d   Harvey Harrison   include: replace ...
57
  # define rt_mutex_init(mutex)			__rt_mutex_init(mutex, __func__)
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
58
59
60
61
   extern void rt_mutex_debug_task_free(struct task_struct *tsk);
  #else
  # define __DEBUG_RT_MUTEX_INITIALIZER(mutexname)
  # define rt_mutex_init(mutex)			__rt_mutex_init(mutex, NULL)
e7eebaf6a   Ingo Molnar   [PATCH] pi-futex:...
62
  # define rt_mutex_debug_task_free(t)			do { } while (0)
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
63
64
65
  #endif
  
  #define __RT_MUTEX_INITIALIZER(mutexname) \
d209d74d5   Thomas Gleixner   rtmutes: Convert ...
66
  	{ .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
732375c6a   Dima Zavin   plist: Remove the...
67
  	, .wait_list = PLIST_HEAD_INIT(mutexname.wait_list) \
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
68
69
70
71
72
  	, .owner = NULL \
  	__DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
  
  #define DEFINE_RT_MUTEX(mutexname) \
  	struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname)
45f8bde0d   Robert P. J. Day   [PATCH] fix vario...
73
  /**
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
   * rt_mutex_is_locked - is the mutex locked
   * @lock: the mutex to be queried
   *
   * Returns 1 if the mutex is locked, 0 if unlocked.
   */
  static inline int rt_mutex_is_locked(struct rt_mutex *lock)
  {
  	return lock->owner != NULL;
  }
  
  extern void __rt_mutex_init(struct rt_mutex *lock, const char *name);
  extern void rt_mutex_destroy(struct rt_mutex *lock);
  
  extern void rt_mutex_lock(struct rt_mutex *lock);
  extern int rt_mutex_lock_interruptible(struct rt_mutex *lock,
  						int detect_deadlock);
  extern int rt_mutex_timed_lock(struct rt_mutex *lock,
  					struct hrtimer_sleeper *timeout,
  					int detect_deadlock);
  
  extern int rt_mutex_trylock(struct rt_mutex *lock);
  
  extern void rt_mutex_unlock(struct rt_mutex *lock);
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
97
98
  #ifdef CONFIG_RT_MUTEXES
  # define INIT_RT_MUTEXES(tsk)						\
732375c6a   Dima Zavin   plist: Remove the...
99
  	.pi_waiters	= PLIST_HEAD_INIT(tsk.pi_waiters),	\
23f78d4a0   Ingo Molnar   [PATCH] pi-futex:...
100
101
102
103
104
105
  	INIT_RT_MUTEX_DEBUG(tsk)
  #else
  # define INIT_RT_MUTEXES(tsk)
  #endif
  
  #endif