diff options
author | unknown <monty@donna.mysql.com> | 2001-01-28 21:41:10 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2001-01-28 21:41:10 +0200 |
commit | 0374dcdd9557002cc6e9747b28a4d01c9259ca6c (patch) | |
tree | 139475fd16658189e77529627fb94bbba4b777f1 /mysys | |
parent | 184e24b2253a81b03476e3d4d8cf56d5eb9dbf18 (diff) | |
parent | 12fd55a5a65dd3d6e6f1ba883d20a86a74aa8d2d (diff) | |
download | mariadb-git-0374dcdd9557002cc6e9747b28a4d01c9259ca6c.tar.gz |
merge
myisam/mi_check.c:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/table.h:
Auto merged
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/Makefile.am | 2 | ||||
-rw-r--r-- | mysys/my_bitmap.c | 60 | ||||
-rw-r--r-- | mysys/my_init.c | 10 | ||||
-rw-r--r-- | mysys/mysys_priv.h | 1 | ||||
-rw-r--r-- | mysys/thr_lock.c | 8 |
5 files changed, 78 insertions, 3 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 7615b85fa29..6674132bdca 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ my_quick.c my_lockmem.c my_static.c \ getopt.c getopt1.c getvar.c my_mkdir.c \ default.c my_compress.c checksum.c raid.cc my_net.c \ - my_vsnprintf.c charset.c + my_vsnprintf.c charset.c my_bitmap.c EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \ thr_mutex.c thr_rwlock.c libmysys_a_LIBADD = @THREAD_LOBJECTS@ diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c new file mode 100644 index 00000000000..1434f472f98 --- /dev/null +++ b/mysys/my_bitmap.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307, USA */ + +/* + Handling of uchar arrays as large bitmaps. +*/ + +#include "mysys_priv.h" +#include <my_bitmap.h> + +pthread_mutex_t LOCK_bitmap; + +void bitmap_set_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) { + if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) { + pthread_mutex_lock(&LOCK_bitmap); + bitmap[bitmap_bit / 8] |= (1 << bitmap_bit % 8); + pthread_mutex_unlock(&LOCK_bitmap); + }; +}; + +uint bitmap_set_next(uchar *bitmap, uint bitmap_size) { + uint bit_found = MY_BIT_NONE; + int i, b; + + pthread_mutex_lock(&LOCK_bitmap); + for(i=0; (i<bitmap_size) && (bit_found==MY_BIT_NONE); i++) { + if(bitmap[i] == 0xff) continue; + for(b=0; (b<8) && (bit_found==MY_BIT_NONE); b++) + if((bitmap[i] & 1<<b) == 0) { + bit_found = (i*8)+b; + bitmap[i] |= 1<<b; + }; + }; + pthread_mutex_unlock(&LOCK_bitmap); + + return bit_found; +}; + +void bitmap_clear_bit(uchar *bitmap, uint bitmap_size, uint bitmap_bit) { + if((bitmap_bit != MY_BIT_NONE) && (bitmap_bit < bitmap_size*8)) { + pthread_mutex_lock(&LOCK_bitmap); + bitmap[bitmap_bit / 8] &= ~(1 << bitmap_bit % 8); + pthread_mutex_unlock(&LOCK_bitmap); + }; +}; + diff --git a/mysys/my_init.c b/mysys/my_init.c index a9c8b49a257..384fab5d53c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -48,6 +48,7 @@ static my_bool win32_init_tcp_ip(); static my_bool my_init_done=0; + static ulong atoi_octal(const char *str) { long int tmp; @@ -76,6 +77,7 @@ void my_init(void) #ifndef __WIN__ sigfillset(&my_signals); /* signals blocked by mf_brkhant */ #endif + pthread_mutex_init(&LOCK_bitmap, NULL); #endif { DBUG_ENTER("my_init"); @@ -127,7 +129,12 @@ void my_end(int infoflag) #ifdef HAVE_GETRUSAGE struct rusage rus; if (!getrusage(RUSAGE_SELF, &rus)) - fprintf(info_file,"\nUser time %.2f, System time %.2f\nMaximum resident set size %ld, Integral resident set size %ld\nNon physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\nBlocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\nVouluntary context switches %ld, Invouluntary context switches %ld\n", + fprintf(info_file,"\n\ +User time %.2f, System time %.2f\n\ +Maximum resident set size %ld, Integral resident set size %ld\n\ +Non-physical pagefaults %ld, Physical pagefaults %ld, Swaps %ld\n\ +Blocks in %ld out %ld, Messages in %ld out %ld, Signals %ld\n\ +Voluntary context switches %ld, Involuntary context switches %ld\n", (rus.ru_utime.tv_sec * SCALE_SEC + rus.ru_utime.tv_usec / SCALE_USEC) / 100.0, (rus.ru_stime.tv_sec * SCALE_SEC + @@ -159,6 +166,7 @@ void my_end(int infoflag) pthread_mutex_destroy(&THR_LOCK_keycache); pthread_mutex_destroy(&THR_LOCK_malloc); pthread_mutex_destroy(&THR_LOCK_open); + pthread_mutex_destroy(&LOCK_bitmap); DBUG_POP(); /* Must be done before my_thread_end */ my_thread_end(); my_thread_global_end(); diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 86c32202e99..20fda270658 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -25,6 +25,7 @@ #ifdef THREAD extern pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open,THR_LOCK_keycache, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_net,THR_LOCK_charset; +extern pthread_mutex_t LOCK_bitmap; #else /* THREAD */ #define pthread_mutex_lock(A) #define pthread_mutex_unlock(A) diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 5c48ad435a4..348c7bae74f 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -83,7 +83,7 @@ multiple read locks. #include <errno.h> my_bool thr_lock_inited=0; - +ulong locks_immediate = 0L, locks_waited = 0L; /* The following constants are only for debug output */ #define MAX_THREADS 100 @@ -387,6 +387,7 @@ static my_bool wait_for_lock(struct st_lock_list *wait, THR_LOCK_DATA *data, else { result=0; + statistic_increment(locks_waited, &THR_LOCK_lock); if (data->lock->get_status) (*data->lock->get_status)(data->status_param); check_locks(data->lock,"got wait_for_lock",0); @@ -447,6 +448,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) check_locks(lock,"read lock with old write lock",0); if (lock->get_status) (*lock->get_status)(data->status_param); + ++locks_immediate; goto end; } if (lock->write.data->type == TL_WRITE_ONLY) @@ -470,6 +472,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) if ((int) lock_type == (int) TL_READ_NO_INSERT) lock->read_no_write_count++; check_locks(lock,"read lock with no write locks",0); + ++locks_immediate; goto end; } /* Can't get lock yet; Wait for it */ @@ -501,6 +504,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) data->cond=get_cond(); if (lock->get_status) (*lock->get_status)(data->status_param); + ++locks_immediate; goto end; } } @@ -535,6 +539,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) check_locks(lock,"second write lock",0); if (data->lock->get_status) (*data->lock->get_status)(data->status_param); + ++locks_immediate; goto end; } DBUG_PRINT("lock",("write locked by thread: %ld", @@ -560,6 +565,7 @@ int thr_lock(THR_LOCK_DATA *data,enum thr_lock_type lock_type) if (data->lock->get_status) (*data->lock->get_status)(data->status_param); check_locks(lock,"only write lock",0); + ++locks_immediate; goto end; } } |