Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 622 → Rev 623

/kernel/trunk/generic/include/synch/rwlock.h
33,6 → 33,7
#include <typedefs.h>
#include <synch/mutex.h>
#include <synch/synch.h>
#include <synch/spinlock.h>
 
enum rwlock_type {
RWLOCK_NONE,
41,7 → 42,7
};
 
struct rwlock {
spinlock_t lock;
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. */
};
/kernel/trunk/generic/include/synch/spinlock.h
41,6 → 41,29
int val;
};
 
/*
* SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
* where the lock gets initialized in run time.
*/
#define SPINLOCK_DECLARE(slname) spinlock_t slname
 
/*
* SPINLOCK_INITIALIZE is to be used for statically allocated spinlocks.
* It declares and initializes the lock.
*/
#ifdef CONFIG_DEBUG_SPINLOCK
#define SPINLOCK_INITIALIZE(slname) \
spinlock_t slname = { \
.name = #slname, \
.val = 0 \
}
#else
#define SPINLOCK_INITIALIZE(slname) \
spinlock_t slname = { \
.val = 0 \
}
#endif
 
extern void spinlock_initialize(spinlock_t *sl, char *name);
extern void spinlock_lock(spinlock_t *sl);
extern int spinlock_trylock(spinlock_t *sl);
48,8 → 71,9
 
#else
 
struct spinlock {
};
/* On UP systems, spinlocks are effectively left out. */
#define SPINLOCK_DECLARE(name)
#define SPINLOCK_INITIALIZE(name)
 
#define spinlock_initialize(x,name)
#define spinlock_lock(x) preemption_disable()
/kernel/trunk/generic/include/synch/waitq.h
45,7 → 45,7
*
* Must be acquired before T.lock for each T of type thread_t.
*/
spinlock_t lock;
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. */