/trunk/kernel/generic/include/synch/futex.h |
---|
42,14 → 42,19 |
/** Kernel-side futex structure. */ |
typedef struct { |
uintptr_t paddr; /**< Physical address of the status variable. */ |
waitq_t wq; /**< Wait queue for threads waiting for futex availability. */ |
link_t ht_link; /**< Futex hash table link. */ |
count_t refcount; /**< Number of tasks that reference this futex. */ |
/** Physical address of the status variable. */ |
uintptr_t paddr; |
/** Wait queue for threads waiting for futex availability. */ |
waitq_t wq; |
/** Futex hash table link. */ |
link_t ht_link; |
/** Number of tasks that reference this futex. */ |
count_t refcount; |
} futex_t; |
extern void futex_init(void); |
extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags); |
extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, |
int flags); |
extern unative_t sys_futex_wakeup(uintptr_t uaddr); |
extern void futex_cleanup(void); |
/trunk/kernel/generic/include/synch/condvar.h |
---|
52,7 → 52,8 |
extern void condvar_initialize(condvar_t *cv); |
extern void condvar_signal(condvar_t *cv); |
extern void condvar_broadcast(condvar_t *cv); |
extern int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags); |
extern int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, |
int flags); |
#endif |
/trunk/kernel/generic/include/synch/rwlock.h |
---|
48,8 → 48,12 |
typedef struct { |
SPINLOCK_DECLARE(lock); |
mutex_t exclusive; /**< Mutex for writers, readers can bypass it if readers_in is positive. */ |
count_t readers_in; /**< Number of readers in critical section. */ |
/** |
* Mutex for writers, readers can bypass it if readers_in is positive. |
*/ |
mutex_t exclusive; |
/** Number of readers in critical section. */ |
count_t readers_in; |
} rwlock_t; |
#define rwlock_write_lock(rwl) \ |
57,9 → 61,11 |
#define rwlock_read_lock(rwl) \ |
_rwlock_read_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE) |
#define rwlock_write_trylock(rwl) \ |
_rwlock_write_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING) |
_rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ |
SYNCH_FLAGS_NON_BLOCKING) |
#define rwlock_read_trylock(rwl) \ |
_rwlock_read_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING) |
_rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ |
SYNCH_FLAGS_NON_BLOCKING) |
#define rwlock_write_lock_timeout(rwl,usec) \ |
_rwlock_write_lock_timeout((rwl),(usec),SYNCH_FLAGS_NONE) |
#define rwlock_read_lock_timeout(rwl,usec) \ |
/trunk/kernel/generic/include/synch/synch.h |
---|
35,20 → 35,31 |
#ifndef KERN_SYNCH_H_ |
#define KERN_SYNCH_H_ |
#define SYNCH_NO_TIMEOUT 0 /**< Request with no timeout. */ |
/** Request with no timeout. */ |
#define SYNCH_NO_TIMEOUT 0 |
#define SYNCH_FLAGS_NONE 0 /**< No flags specified. */ |
#define SYNCH_FLAGS_NON_BLOCKING (1<<0) /**< Non-blocking operation request. */ |
#define SYNCH_FLAGS_INTERRUPTIBLE (1<<1) /**< Interruptible operation. */ |
/** No flags specified. */ |
#define SYNCH_FLAGS_NONE 0 |
/** Non-blocking operation request. */ |
#define SYNCH_FLAGS_NON_BLOCKING (1 << 0) |
/** Interruptible operation. */ |
#define SYNCH_FLAGS_INTERRUPTIBLE (1 << 1) |
#define ESYNCH_WOULD_BLOCK 1 /**< Could not satisfy the request without going to sleep. */ |
#define ESYNCH_TIMEOUT 2 /**< Timeout occurred. */ |
#define ESYNCH_INTERRUPTED 4 /**< Sleep was interrupted. */ |
#define ESYNCH_OK_ATOMIC 8 /**< Operation succeeded without sleeping. */ |
#define ESYNCH_OK_BLOCKED 16 /**< Operation succeeded and did sleep. */ |
/** Could not satisfy the request without going to sleep. */ |
#define ESYNCH_WOULD_BLOCK 1 |
/** Timeout occurred. */ |
#define ESYNCH_TIMEOUT 2 |
/** Sleep was interrupted. */ |
#define ESYNCH_INTERRUPTED 4 |
/** Operation succeeded without sleeping. */ |
#define ESYNCH_OK_ATOMIC 8 |
/** Operation succeeded and did sleep. */ |
#define ESYNCH_OK_BLOCKED 16 |
#define SYNCH_FAILED(rc) ((rc) & (ESYNCH_WOULD_BLOCK | ESYNCH_TIMEOUT | ESYNCH_INTERRUPTED)) |
#define SYNCH_OK(rc) ((rc) & (ESYNCH_OK_ATOMIC | ESYNCH_OK_BLOCKED)) |
#define SYNCH_FAILED(rc) \ |
((rc) & (ESYNCH_WOULD_BLOCK | ESYNCH_TIMEOUT | ESYNCH_INTERRUPTED)) |
#define SYNCH_OK(rc) \ |
((rc) & (ESYNCH_OK_ATOMIC | ESYNCH_OK_BLOCKED)) |
#endif |
/trunk/kernel/generic/include/synch/waitq.h |
---|
52,8 → 52,12 |
*/ |
SPINLOCK_DECLARE(lock); |
int missed_wakeups; /**< Number of waitq_wakeup() calls that didn't find a thread to wake up. */ |
link_t head; /**< List of sleeping threads for wich there was no missed_wakeup. */ |
/** |
* Number of waitq_wakeup() calls that didn't find a thread to wake up. |
*/ |
int missed_wakeups; |
/** List of sleeping threads for wich there was no missed_wakeup. */ |
link_t head; |
} waitq_t; |
#define waitq_sleep(wq) \ |