Commit aad040fd authored by unknown's avatar unknown

comments


storage/maria/tablockman.c:
  comments. bugfix - a special case in release_locks
storage/maria/unittest/lockman1-t.c:
  updated
storage/maria/unittest/lockman2-t.c:
  new tests
parent 96d3604d
This diff is collapsed.
......@@ -51,34 +51,38 @@ typedef TABLE_LOCK_OWNER *loid_to_tlo_func(uint16);
typedef struct {
pthread_mutex_t pool_mutex;
TABLE_LOCK *pool;
TABLE_LOCK *pool; /* lifo pool of free locks */
uint lock_timeout;
loid_to_tlo_func *loid_to_lo;
loid_to_tlo_func *loid_to_tlo; /* for mapping loid to TABLE_LOCK_OWNER */
} TABLOCKMAN;
struct st_table_lock_owner {
TABLE_LOCK *active_locks, *waiting_lock;
TABLE_LOCK_OWNER *waiting_for;
pthread_cond_t *cond; /* transactions waiting for this, wait on 'cond' */
TABLE_LOCK *active_locks; /* list of active locks */
TABLE_LOCK *waiting_lock; /* waiting lock (one lock only) */
TABLE_LOCK_OWNER *waiting_for; /* transaction we're wating for */
pthread_cond_t *cond; /* transactions waiting for us, wait on 'cond' */
pthread_mutex_t *mutex; /* mutex is required to use 'cond' */
uint16 loid;
uint16 loid; /* Lock Owner IDentifier */
};
struct st_locked_table {
pthread_mutex_t mutex;
HASH active; // fast to remove
TABLE_LOCK *active_locks[LOCK_TYPES]; // fast to see a conflict
TABLE_LOCK *wait_queue_in, *wait_queue_out;
pthread_mutex_t mutex; /* mutex for everything below */
HASH active; /* active locks ina hash */
TABLE_LOCK *active_locks[LOCK_TYPES]; /* dl-list of locks per type */
TABLE_LOCK *wait_queue_in, *wait_queue_out; /* wait deque */
};
void tablockman_init(TABLOCKMAN *, loid_to_tlo_func *, uint);
void tablockman_destroy(TABLOCKMAN *);
enum lockman_getlock_result tablockman_getlock(TABLOCKMAN *, TABLE_LOCK_OWNER *,
LOCKED_TABLE *,
enum lock_type lock);
LOCKED_TABLE *, enum lock_type);
void tablockman_release_locks(TABLOCKMAN *, TABLE_LOCK_OWNER *);
void tablockman_init_locked_table(LOCKED_TABLE *);
void tablockman_init_locked_table(LOCKED_TABLE *, int);
void tablockman_destroy_locked_table(LOCKED_TABLE *);
#ifdef EXTRA_DEBUG
void print_tlo(TABLE_LOCK_OWNER *);
#endif
#endif
......@@ -288,10 +288,10 @@ int main()
for (i= 0; i < Ntbls; i++)
{
tablockman_init_locked_table(ltarray+i);
tablockman_init_locked_table(ltarray+i, Nlos);
}
//test_tablockman_simple();
test_tablockman_simple();
#define CYCLES 10000
#define THREADS Nlos /* don't change this line */
......
......@@ -115,6 +115,20 @@ void test_tablockman_simple()
lock_conflict(2, 1, X);
unlock_all(1);
unlock_all(2);
lock_ok_i(1, 1, IS);
lock_conflict(2, 1, X);
lock_conflict(3, 1, IS);
unlock_all(1);
unlock_all(2);
unlock_all(3);
lock_ok_a(1, 1, S);
lock_conflict(2, 1, IX);
lock_conflict(3, 1, IS);
unlock_all(1);
unlock_all(2);
unlock_all(3);
}
int rt_num_threads;
......@@ -273,7 +287,7 @@ int main()
for (i= 0; i < Ntbls; i++)
{
tablockman_init_locked_table(ltarray+i);
tablockman_init_locked_table(ltarray+i, Nlos);
}
test_tablockman_simple();
......@@ -285,7 +299,7 @@ int main()
Nrows= 100;
Ntables= 10;
table_lock_ratio= 10;
run_test("\"random lock\" stress test", test_lockman, THREADS, CYCLES);
//run_test("\"random lock\" stress test", test_lockman, THREADS, CYCLES);
#if 0
/* "real-life" simulation - many rows, no table locks */
Nrows= 1000000;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment