1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

wt needs to use its own implementation of rwlocks with

reader preference, at least where system rwlocks are fair.

include/my_global.h:
  wt uses mutex-based rwlock implementation unless on linux
include/waiting_threads.h:
  mutex-based rwlock implementation with reader preference
mysys/thr_rwlock.c:
  revert the change. make my_rw_locks fair
mysys/waiting_threads.c:
  mutex-based rwlock implementation with reader preference.
  convert complex multi-line macros to static functions
This commit is contained in:
Sergei Golubchik
2008-10-24 12:34:08 +02:00
parent 9fb894540e
commit 14c1466187
4 changed files with 131 additions and 57 deletions

View File

@@ -67,7 +67,6 @@ extern uint32 wt_success_stats;
e.g. accessing a resource by thd->waiting_for is safe,
a resource cannot be freed as there's a thread waiting for it
*/
typedef struct st_wt_resource {
WT_RESOURCE_ID id;
uint waiter_count;
@@ -76,11 +75,27 @@ typedef struct st_wt_resource {
pthread_mutex_t *mutex;
#endif
/*
before the 'lock' all elements are mutable, after - immutable
in the sense that lf_hash_insert() won't memcpy() over them.
before the 'lock' all elements are mutable, after (and including) -
immutable in the sense that lf_hash_insert() won't memcpy() over them.
See wt_init().
*/
#ifdef WT_RWLOCKS_USE_MUTEXES
/*
we need a special rwlock-like 'lock' to allow readers bypass
waiting writers, otherwise readers can deadlock.
writer starvation is technically possible, but unlikely, because
the contention is expected to be low.
*/
struct {
pthread_cond_t cond;
pthread_mutex_t mutex;
uint readers: 16;
uint pending_writers: 15;
uint write_locked: 1;
} lock;
#else
rw_lock_t lock;
#endif
pthread_cond_t cond;
DYNAMIC_ARRAY owners;
} WT_RESOURCE;