19 #ifndef _POSIX_MUTEX_H
20 #define _POSIX_MUTEX_H
22 #include <asm/xenomai/atomic.h>
28 pthread_mutex_t native_mutex;
29 struct __shadow_mutex {
32 struct pse51_mutex *mutex;
34 #ifdef CONFIG_XENO_FASTSYNCH
36 unsigned owner_offset;
37 xnarch_atomic_t *owner;
39 struct pse51_mutexattr attr;
44 #if defined(__KERNEL__) || defined(__XENO_SIM__)
46 #include <posix/internal.h>
47 #include <posix/thread.h>
48 #include <posix/cb_lock.h>
50 typedef struct pse51_mutex {
55 #define link2mutex(laddr) \
56 ((pse51_mutex_t *)(((char *)laddr) - offsetof(pse51_mutex_t, link)))
58 pthread_mutexattr_t attr;
59 pse51_kqueues_t *owningq;
62 extern pthread_mutexattr_t pse51_default_mutex_attr;
64 void pse51_mutexq_cleanup(pse51_kqueues_t *q);
66 void pse51_mutex_pkg_init(
void);
68 void pse51_mutex_pkg_cleanup(
void);
71 int pse51_mutex_timedlock_break(
struct __shadow_mutex *shadow,
72 int timed, xnticks_t to);
74 int pse51_mutex_check_init(
struct __shadow_mutex *shadow,
75 const pthread_mutexattr_t *attr);
77 int pse51_mutex_init_internal(
struct __shadow_mutex *shadow,
79 xnarch_atomic_t *ownerp,
80 const pthread_mutexattr_t *attr);
82 void pse51_mutex_destroy_internal(pse51_mutex_t *mutex,
86 static inline int pse51_mutex_timedlock_internal(xnthread_t *cur,
87 struct __shadow_mutex *shadow,
93 pse51_mutex_t *mutex = shadow->mutex;
95 if (xnpod_unblockable_p())
98 if (!pse51_obj_active(shadow, PSE51_MUTEX_MAGIC,
struct __shadow_mutex)
99 || !pse51_obj_active(mutex, PSE51_MUTEX_MAGIC,
struct pse51_mutex))
102 #if XENO_DEBUG(POSIX)
103 if (mutex->owningq != pse51_kqueues(mutex->attr.pshared))
107 if (xnsynch_owner_check(&mutex->synchbase, cur) == 0)
116 if (xnthread_test_info(cur,
XNBREAK))
118 else if (xnthread_test_info(cur,
XNTIMEO))
124 shadow->lockcnt = count;
xnflags_t xnsynch_acquire(struct xnsynch *synch, xnticks_t timeout, xntmode_t timeout_mode)
Acquire the ownership of a synchronization object.
Definition: synch.c:406
#define XNTIMEO
Woken up due to a timeout condition.
Definition: thread.h:108
#define XNRMID
Pending on a removed resource.
Definition: thread.h:109
#define XNBREAK
Forcibly awaken from a wait state.
Definition: thread.h:110