19 #ifndef _COBALT_KERNEL_SYNCH_H 20 #define _COBALT_KERNEL_SYNCH_H 22 #include <cobalt/kernel/list.h> 23 #include <cobalt/kernel/assert.h> 24 #include <cobalt/kernel/timer.h> 25 #include <cobalt/uapi/kernel/synch.h> 31 #define XNSYNCH_CLAIMED 0x10 34 #define XNSYNCH_SPARE0 0x01000000 35 #define XNSYNCH_SPARE1 0x02000000 36 #define XNSYNCH_SPARE2 0x04000000 37 #define XNSYNCH_SPARE3 0x08000000 38 #define XNSYNCH_SPARE4 0x10000000 39 #define XNSYNCH_SPARE5 0x20000000 40 #define XNSYNCH_SPARE6 0x40000000 41 #define XNSYNCH_SPARE7 0x80000000 44 #define XNSYNCH_DONE 0 45 #define XNSYNCH_WAIT 1 46 #define XNSYNCH_RESCHED 2 52 struct list_head link;
55 struct list_head pendq;
56 struct xnthread *owner;
58 void (*cleanup)(
struct xnsynch *synch);
61 #define XNSYNCH_WAITQUEUE_INITIALIZER(__name) { \ 62 .status = XNSYNCH_PRIO, \ 64 .pendq = LIST_HEAD_INIT((__name).pendq), \ 70 #define DEFINE_XNWAITQ(__name) \ 71 struct xnsynch __name = XNSYNCH_WAITQUEUE_INITIALIZER(__name) 73 static inline void xnsynch_set_status(
struct xnsynch *synch,
int bits)
75 synch->status |= bits;
78 static inline void xnsynch_clear_status(
struct xnsynch *synch,
int bits)
80 synch->status &= ~bits;
83 #define xnsynch_for_each_sleeper(__pos, __synch) \ 84 list_for_each_entry(__pos, &(__synch)->pendq, plink) 86 #define xnsynch_for_each_sleeper_safe(__pos, __tmp, __synch) \ 87 list_for_each_entry_safe(__pos, __tmp, &(__synch)->pendq, plink) 89 static inline int xnsynch_pended_p(
struct xnsynch *synch)
91 return !list_empty(&synch->pendq);
94 static inline struct xnthread *xnsynch_owner(
struct xnsynch *synch)
99 #define xnsynch_fastlock(synch) ((synch)->fastlock) 100 #define xnsynch_fastlock_p(synch) ((synch)->fastlock != NULL) 101 #define xnsynch_owner_check(synch, thread) \ 102 xnsynch_fast_owner_check((synch)->fastlock, thread->handle) 104 #if XENO_DEBUG(MUTEX_RELAXED) 106 void xnsynch_detect_relaxed_owner(
struct xnsynch *synch,
107 struct xnthread *sleeper);
109 void xnsynch_detect_claimed_relax(
struct xnthread *owner);
113 static inline void xnsynch_detect_relaxed_owner(
struct xnsynch *synch,
114 struct xnthread *sleeper)
118 static inline void xnsynch_detect_claimed_relax(
struct xnthread *owner)
129 static inline void xnsynch_set_owner(
struct xnsynch *synch,
130 struct xnthread *thread)
132 synch->owner = thread;
135 static inline void xnsynch_register_cleanup(
struct xnsynch *synch,
136 void (*handler)(
struct xnsynch *))
138 synch->cleanup = handler;
143 xntmode_t timeout_mode);
147 int xnsynch_wakeup_many_sleepers(
struct xnsynch *synch,
int nr);
150 struct xnthread *sleeper);
154 xntmode_t timeout_mode);
159 struct xnthread *thread);
165 void xnsynch_release_all_ownerships(
struct xnthread *thread);
167 void xnsynch_requeue_sleeper(
struct xnthread *thread);
169 void xnsynch_forget_sleeper(
struct xnthread *thread);
int xnsynch_flush(struct xnsynch *synch, int reason)
Unblock all waiters pending on a resource.
Definition: synch.c:810
struct xnthread * xnsynch_release(struct xnsynch *synch, struct xnthread *thread)
Give the resource ownership to the next waiting thread.
Definition: synch.c:662
int xnsynch_destroy(struct xnsynch *synch)
Destroy a synchronization object.
Definition: synch.c:117
int __must_check xnsynch_acquire(struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)
Acquire the ownership of a synchronization object.
Definition: synch.c:424
void xnsynch_wakeup_this_sleeper(struct xnsynch *synch, struct xnthread *sleeper)
Unblock a particular thread from wait.
Definition: synch.c:292
struct xnthread * xnsynch_wakeup_one_sleeper(struct xnsynch *synch)
Unblock the heading thread from wait.
Definition: synch.c:216
int __must_check xnsynch_sleep_on(struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)
Sleep on an ownerless synchronization object.
Definition: synch.c:162
void xnsynch_init(struct xnsynch *synch, int flags, atomic_t *fastlock)
Initialize a synchronization object.
Definition: synch.c:81
int __must_check xnsynch_try_acquire(struct xnsynch *synch)
Try acquiring the ownership of a synchronization object.
Definition: synch.c:360
Copyright © 2011 Gilles Chanteperdrix gilles.chanteperdrix@xenomai.org.
Definition: atomic.h:24
struct xnthread * xnsynch_peek_pendq(struct xnsynch *synch)
Access the thread leading a synch object wait queue.
Definition: synch.c:750