summaryrefslogtreecommitdiff
path: root/mysys/wqueue.c
diff options
context:
space:
mode:
authorunknown <bell@88-214-96-46.dialup.umc.net.ua>2008-02-22 22:32:34 +0200
committerunknown <bell@88-214-96-46.dialup.umc.net.ua>2008-02-22 22:32:34 +0200
commit190de95f6fcf37572be7cf2ff0543d74d190a989 (patch)
tree0ccc2ad2a6bfe277f9795c8e8a468213842a80a1 /mysys/wqueue.c
parent3aaa0f60cdc0f1c63221ae7ac6e0ce2f11a175cb (diff)
downloadmariadb-git-190de95f6fcf37572be7cf2ff0543d74d190a989.tar.gz
Locking for read and write made waiting for each other (with loose
scheme for the same thread locking). include/my_pthread.h: Added variable for lock diffirentiation. include/wqueue.h: New release call. mysys/wqueue.c: New release call in case of read/write lock. storage/maria/ma_pagecache.c: Locking for read and write made waitimg for each other. storage/maria/unittest/Makefile.am: New test added. storage/maria/unittest/ma_pagecache_consist.c: Fixed thread initialization in the test. storage/maria/unittest/ma_pagecache_rwconsist.c: New BitKeeper file ``storage/maria/unittest/ma_pagecache_rwconsist.c''
Diffstat (limited to 'mysys/wqueue.c')
-rw-r--r--mysys/wqueue.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/mysys/wqueue.c b/mysys/wqueue.c
index bfe9cba1235..0766e13a4e4 100644
--- a/mysys/wqueue.c
+++ b/mysys/wqueue.c
@@ -136,6 +136,49 @@ void wqueue_release_queue(WQUEUE *wqueue)
}
+/**
+ @brief Removes all threads waiting for read or first one waiting for write.
+
+ @param wqueue pointer to the queue structure
+ @apram thread pointer to the thread to be added to the queue
+*/
+
+void wqueue_release_one_locktype_from_queue(WQUEUE *wqueue)
+{
+ struct st_my_thread_var *last= wqueue->last_thread;
+ struct st_my_thread_var *next= last->next;
+ struct st_my_thread_var **prev= &wqueue->last_thread;
+ struct st_my_thread_var *thread;
+ uint first_type= next->lock_type;
+ if (first_type == MY_PTHREAD_LOCK_WRITE)
+ {
+ /* release first waiting for write lock */
+ thread= next;
+ pthread_cond_signal(&thread->suspend);
+ wqueue->last_thread= next;
+ thread->next= NULL;
+ return;
+ }
+ do
+ {
+ thread= next;
+ next= thread->next;
+ if (thread->lock_type == MY_PTHREAD_LOCK_WRITE)
+ {
+ /* skip waiting for write lock */
+ *prev= thread;
+ prev= &thread->next;
+ }
+ else
+ {
+ /* release waiting for read lock */
+ pthread_cond_signal(&thread->suspend);
+ thread->next= NULL;
+ }
+ } while (thread != last);
+ *prev= NULL;
+}
+
/*
Add thread and wait