Changeset 80bcaed in mainline for kernel/generic/include/synch
- Timestamp:
- 2007-02-03T13:22:24Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f619ec11
- Parents:
- fa8e7d2
- Location:
- kernel/generic/include/synch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/synch/condvar.h
rfa8e7d2 r80bcaed 45 45 } condvar_t; 46 46 47 #define condvar_wait(cv, mtx) \48 _condvar_wait_timeout((cv), (mtx),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)49 #define condvar_wait_timeout(cv, mtx,usec) \50 _condvar_wait_timeout((cv), (mtx),(usec),SYNCH_FLAGS_NONE)47 #define condvar_wait(cv, mtx) \ 48 _condvar_wait_timeout((cv), (mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 49 #define condvar_wait_timeout(cv, mtx, usec) \ 50 _condvar_wait_timeout((cv), (mtx), (usec), SYNCH_FLAGS_NONE) 51 51 52 52 extern void condvar_initialize(condvar_t *cv); 53 53 extern void condvar_signal(condvar_t *cv); 54 54 extern void condvar_broadcast(condvar_t *cv); 55 extern int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, int flags); 55 extern int _condvar_wait_timeout(condvar_t *cv, mutex_t *mtx, uint32_t usec, 56 int flags); 56 57 57 58 #endif -
kernel/generic/include/synch/futex.h
rfa8e7d2 r80bcaed 43 43 /** Kernel-side futex structure. */ 44 44 typedef struct { 45 uintptr_t paddr; /**< Physical address of the status variable. */ 46 waitq_t wq; /**< Wait queue for threads waiting for futex availability. */ 47 link_t ht_link; /**< Futex hash table link. */ 48 count_t refcount; /**< Number of tasks that reference this futex. */ 45 /** Physical address of the status variable. */ 46 uintptr_t paddr; 47 /** Wait queue for threads waiting for futex availability. */ 48 waitq_t wq; 49 /** Futex hash table link. */ 50 link_t ht_link; 51 /** Number of tasks that reference this futex. */ 52 count_t refcount; 49 53 } futex_t; 50 54 51 55 extern void futex_init(void); 52 extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, int flags); 56 extern unative_t sys_futex_sleep_timeout(uintptr_t uaddr, uint32_t usec, 57 int flags); 53 58 extern unative_t sys_futex_wakeup(uintptr_t uaddr); 54 59 -
kernel/generic/include/synch/rwlock.h
rfa8e7d2 r80bcaed 49 49 typedef struct { 50 50 SPINLOCK_DECLARE(lock); 51 mutex_t exclusive; /**< Mutex for writers, readers can bypass it if readers_in is positive. */ 52 count_t readers_in; /**< Number of readers in critical section. */ 51 /** 52 * Mutex for writers, readers can bypass it if readers_in is positive. 53 */ 54 mutex_t exclusive; 55 /** Number of readers in critical section. */ 56 count_t readers_in; 53 57 } rwlock_t; 54 58 55 59 #define rwlock_write_lock(rwl) \ 56 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)60 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 57 61 #define rwlock_read_lock(rwl) \ 58 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)62 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 59 63 #define rwlock_write_trylock(rwl) \ 60 _rwlock_write_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING) 64 _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 65 SYNCH_FLAGS_NON_BLOCKING) 61 66 #define rwlock_read_trylock(rwl) \ 62 _rwlock_read_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NON_BLOCKING) 63 #define rwlock_write_lock_timeout(rwl,usec) \ 64 _rwlock_write_lock_timeout((rwl),(usec),SYNCH_FLAGS_NONE) 65 #define rwlock_read_lock_timeout(rwl,usec) \ 66 _rwlock_read_lock_timeout((rwl),(usec),SYNCH_FLAGS_NONE) 67 _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \ 68 SYNCH_FLAGS_NON_BLOCKING) 69 #define rwlock_write_lock_timeout(rwl, usec) \ 70 _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 71 #define rwlock_read_lock_timeout(rwl, usec) \ 72 _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE) 67 73 68 74 extern void rwlock_initialize(rwlock_t *rwl); -
kernel/generic/include/synch/semaphore.h
rfa8e7d2 r80bcaed 47 47 _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE) 48 48 #define semaphore_trydown(s) \ 49 _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING) 49 _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING) 50 50 #define semaphore_down_timeout(s, usec) \ 51 51 _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE) -
kernel/generic/include/synch/synch.h
rfa8e7d2 r80bcaed 36 36 #define KERN_SYNCH_H_ 37 37 38 #define SYNCH_NO_TIMEOUT 0 /**< Request with no timeout. */ 38 /** Request with no timeout. */ 39 #define SYNCH_NO_TIMEOUT 0 39 40 40 #define SYNCH_FLAGS_NONE 0 /**< No flags specified. */ 41 #define SYNCH_FLAGS_NON_BLOCKING (1<<0) /**< Non-blocking operation request. */ 42 #define SYNCH_FLAGS_INTERRUPTIBLE (1<<1) /**< Interruptible operation. */ 41 /** No flags specified. */ 42 #define SYNCH_FLAGS_NONE 0 43 /** Non-blocking operation request. */ 44 #define SYNCH_FLAGS_NON_BLOCKING (1 << 0) 45 /** Interruptible operation. */ 46 #define SYNCH_FLAGS_INTERRUPTIBLE (1 << 1) 43 47 44 #define ESYNCH_WOULD_BLOCK 1 /**< Could not satisfy the request without going to sleep. */ 45 #define ESYNCH_TIMEOUT 2 /**< Timeout occurred. */ 46 #define ESYNCH_INTERRUPTED 4 /**< Sleep was interrupted. */ 47 #define ESYNCH_OK_ATOMIC 8 /**< Operation succeeded without sleeping. */ 48 #define ESYNCH_OK_BLOCKED 16 /**< Operation succeeded and did sleep. */ 48 /** Could not satisfy the request without going to sleep. */ 49 #define ESYNCH_WOULD_BLOCK 1 50 /** Timeout occurred. */ 51 #define ESYNCH_TIMEOUT 2 52 /** Sleep was interrupted. */ 53 #define ESYNCH_INTERRUPTED 4 54 /** Operation succeeded without sleeping. */ 55 #define ESYNCH_OK_ATOMIC 8 56 /** Operation succeeded and did sleep. */ 57 #define ESYNCH_OK_BLOCKED 16 49 58 50 #define SYNCH_FAILED(rc) ((rc) & (ESYNCH_WOULD_BLOCK | ESYNCH_TIMEOUT | ESYNCH_INTERRUPTED)) 51 #define SYNCH_OK(rc) ((rc) & (ESYNCH_OK_ATOMIC | ESYNCH_OK_BLOCKED)) 59 #define SYNCH_FAILED(rc) \ 60 ((rc) & (ESYNCH_WOULD_BLOCK | ESYNCH_TIMEOUT | ESYNCH_INTERRUPTED)) 61 #define SYNCH_OK(rc) \ 62 ((rc) & (ESYNCH_OK_ATOMIC | ESYNCH_OK_BLOCKED)) 52 63 53 64 #endif -
kernel/generic/include/synch/waitq.h
rfa8e7d2 r80bcaed 53 53 SPINLOCK_DECLARE(lock); 54 54 55 int missed_wakeups; /**< Number of waitq_wakeup() calls that didn't find a thread to wake up. */ 56 link_t head; /**< List of sleeping threads for wich there was no missed_wakeup. */ 55 /** 56 * Number of waitq_wakeup() calls that didn't find a thread to wake up. 57 */ 58 int missed_wakeups; 59 /** List of sleeping threads for wich there was no missed_wakeup. */ 60 link_t head; 57 61 } waitq_t; 58 62
Note:
See TracChangeset
for help on using the changeset viewer.