aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rtmutex.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2006-06-27 05:54:53 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-27 20:32:47 -0400
commit23f78d4a03c53cbd75d87a795378ea540aa08c86 (patch)
tree27dfe06337990911380fe8c5949ae9acd8e9568a /include/linux/rtmutex.h
parentb29739f902ee76a05493fb7d2303490fc75364f4 (diff)
[PATCH] pi-futex: rt mutex core
Core functions for the rt-mutex subsystem. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/rtmutex.h')
-rw-r--r--include/linux/rtmutex.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
new file mode 100644
index 000000000000..12309c916c68
--- /dev/null
+++ b/include/linux/rtmutex.h
@@ -0,0 +1,104 @@
1/*
2 * RT Mutexes: blocking mutual exclusion locks with PI support
3 *
4 * started by Ingo Molnar and Thomas Gleixner:
5 *
6 * Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 * Copyright (C) 2006, Timesys Corp., Thomas Gleixner <tglx@timesys.com>
8 *
9 * This file contains the public data structure and API definitions.
10 */
11
12#ifndef __LINUX_RT_MUTEX_H
13#define __LINUX_RT_MUTEX_H
14
15#include <linux/linkage.h>
16#include <linux/plist.h>
17#include <linux/spinlock_types.h>
18
19/*
20 * The rt_mutex structure
21 *
22 * @wait_lock: spinlock to protect the structure
23 * @wait_list: pilist head to enqueue waiters in priority order
24 * @owner: the mutex owner
25 */
26struct rt_mutex {
27 spinlock_t wait_lock;
28 struct plist_head wait_list;
29 struct task_struct *owner;
30#ifdef CONFIG_DEBUG_RT_MUTEXES
31 int save_state;
32 struct list_head held_list_entry;
33 unsigned long acquire_ip;
34 const char *name, *file;
35 int line;
36 void *magic;
37#endif
38};
39
40struct rt_mutex_waiter;
41struct hrtimer_sleeper;
42
43#ifdef CONFIG_DEBUG_RT_MUTEXES
44# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname) \
45 , .name = #mutexname, .file = __FILE__, .line = __LINE__
46# define rt_mutex_init(mutex) __rt_mutex_init(mutex, __FUNCTION__)
47 extern void rt_mutex_debug_task_free(struct task_struct *tsk);
48#else
49# define __DEBUG_RT_MUTEX_INITIALIZER(mutexname)
50# define rt_mutex_init(mutex) __rt_mutex_init(mutex, NULL)
51# define rt_mutex_debug_task_free(t) do { } while (0)
52#endif
53
54#define __RT_MUTEX_INITIALIZER(mutexname) \
55 { .wait_lock = SPIN_LOCK_UNLOCKED \
56 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
57 , .owner = NULL \
58 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
59
60#define DEFINE_RT_MUTEX(mutexname) \
61 struct rt_mutex mutexname = __RT_MUTEX_INITIALIZER(mutexname)
62
63/***
64 * rt_mutex_is_locked - is the mutex locked
65 * @lock: the mutex to be queried
66 *
67 * Returns 1 if the mutex is locked, 0 if unlocked.
68 */
69static inline int rt_mutex_is_locked(struct rt_mutex *lock)
70{
71 return lock->owner != NULL;
72}
73
74extern void __rt_mutex_init(struct rt_mutex *lock, const char *name);
75extern void rt_mutex_destroy(struct rt_mutex *lock);
76
77extern void rt_mutex_lock(struct rt_mutex *lock);
78extern int rt_mutex_lock_interruptible(struct rt_mutex *lock,
79 int detect_deadlock);
80extern int rt_mutex_timed_lock(struct rt_mutex *lock,
81 struct hrtimer_sleeper *timeout,
82 int detect_deadlock);
83
84extern int rt_mutex_trylock(struct rt_mutex *lock);
85
86extern void rt_mutex_unlock(struct rt_mutex *lock);
87
88#ifdef CONFIG_DEBUG_RT_MUTEXES
89# define INIT_RT_MUTEX_DEBUG(tsk) \
90 .held_list_head = LIST_HEAD_INIT(tsk.held_list_head), \
91 .held_list_lock = SPIN_LOCK_UNLOCKED
92#else
93# define INIT_RT_MUTEX_DEBUG(tsk)
94#endif
95
96#ifdef CONFIG_RT_MUTEXES
97# define INIT_RT_MUTEXES(tsk) \
98 .pi_waiters = PLIST_HEAD_INIT(tsk.pi_waiters, tsk.pi_lock), \
99 INIT_RT_MUTEX_DEBUG(tsk)
100#else
101# define INIT_RT_MUTEXES(tsk)
102#endif
103
104#endif