????Linux?????????????????????????????????????????????????????壬???????????????RCU??????????????????????????????÷???
?????????? ?????? ???д??
???????
????1. ???????????
????2. ?????????????????????????trylock??????????????
????3. ???????ж??С?
????4. ?κ??????????????????????????????
????5. ??????ж????????????????
????6. ????????????????????????
????spin_lock??y???
void spin_lock_init(spinlock_t *lock);
//init
void spin_lock(spinlock_t *lock);
// ?????
void spin_unlock(spinlock_t *lock);
//?????
????????
typedef struct spinlock {
union {
struct raw_spinlock rlock;
#ifdef CONFIG_DEBUG_LOCK_ALLOC
# define LOCK_PADSIZE (offsetof(struct raw_spinlock?? dep_map))
struct {
u8 __padding[LOCK_PADSIZE];
struct lockdep_map dep_map;
};
#endif
};
} spinlock_t;
????Rwlock?? ??д??????????????????????????????????????????????????????????????????Ч???????????????????????????????????????N?????????????д???????д?????????ж???д??????
??????????????д????????????д????????????????????????????????????????????£??????Щ?????????????滹????????????????д???????????д?????????????
??????y???
rwlock_init(lock)??
//init
read_lock??lock??;
//???????
read_unlock(lock) ;
write_lock (lock);
//???д??
write_unlock(lock);
/*
* include/linux/rwlock_types.h - generic rwlock type definitions
*                 and initializers
*
* portions Copyright 2005?? Red Hat?? Inc.?? Ingo Molnar
* Released under the General Public License (GPL).
*/
typedef struct {
arch_rwlock_t raw_lock;
#ifdef CONFIG_GENERIC_LOCKBREAK
unsigned int break_lock;
#endif
#ifdef CONFIG_DEBUG_SPINLOCK
unsigned int magic?? owner_cpu;
void *owner;
#endif
#ifdef CONFIG_DEBUG_LOCK_ALLOC
struct lockdep_map dep_map;
#endif
} rwlock_t;