Subversion Repositories HelenOS

Rev

Rev 2071 | Rev 2089 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2085
Line 39... Line 39...
39
#include <typedefs.h>
39
#include <typedefs.h>
40
#include <synch/mutex.h>
40
#include <synch/mutex.h>
41
#include <synch/synch.h>
41
#include <synch/synch.h>
42
#include <synch/spinlock.h>
42
#include <synch/spinlock.h>
43
 
43
 
44
enum rwlock_type {
44
typedef enum {
45
    RWLOCK_NONE,
45
    RWLOCK_NONE,
46
    RWLOCK_READER,
46
    RWLOCK_READER,
47
    RWLOCK_WRITER
47
    RWLOCK_WRITER
48
};
48
} rwlock_type_t;
49
 
49
 
50
struct rwlock {
50
typedef struct {
51
    SPINLOCK_DECLARE(lock);
51
    SPINLOCK_DECLARE(lock);
52
    mutex_t exclusive;  /**< Mutex for writers, readers can bypass it if readers_in is positive. */
52
    mutex_t exclusive;  /**< Mutex for writers, readers can bypass it if readers_in is positive. */
53
    count_t readers_in; /**< Number of readers in critical section. */
53
    count_t readers_in; /**< Number of readers in critical section. */
54
};
54
} rwlock_t;
55
 
55
 
56
#define rwlock_write_lock(rwl) \
56
#define rwlock_write_lock(rwl) \
57
    _rwlock_write_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
57
    _rwlock_write_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
58
#define rwlock_read_lock(rwl) \
58
#define rwlock_read_lock(rwl) \
59
    _rwlock_read_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)
59
    _rwlock_read_lock_timeout((rwl),SYNCH_NO_TIMEOUT,SYNCH_FLAGS_NONE)