1201
1201
#include <my_sys.h>
1203
static void thr_print_lock(const char* name,struct st_lock_list *list)
1205
THR_LOCK_DATA *data,**prev;
1210
printf("%-10s: ",name);
1212
for (data=list->data; data && count++ < MAX_LOCKS ; data=data->next)
1214
printf("0x%lx (%lu:%d); ", (ulong) data, data->owner->info->thread_id,
1216
if (data->prev != prev)
1217
printf("\nWarning: prev didn't point at previous lock\n");
1221
if (prev != list->last)
1222
printf("Warning: last didn't point at last lock\n");
1226
void thr_print_locks(void)
1231
pthread_mutex_lock(&THR_LOCK_lock);
1232
puts("Current locks:");
1233
for (list= thr_lock_thread_list; list && count++ < MAX_THREADS;
1234
list= list_rest(list))
1236
THR_LOCK *lock=(THR_LOCK*) list->data;
1237
VOID(pthread_mutex_lock(&lock->mutex));
1238
printf("lock: 0x%lx:",(ulong) lock);
1239
if ((lock->write_wait.data || lock->read_wait.data) &&
1240
(! lock->read.data && ! lock->write.data))
1241
printf(" WARNING: ");
1242
if (lock->write.data)
1244
if (lock->write_wait.data)
1245
printf(" write_wait");
1246
if (lock->read.data)
1248
if (lock->read_wait.data)
1249
printf(" read_wait");
1251
thr_print_lock("write",&lock->write);
1252
thr_print_lock("write_wait",&lock->write_wait);
1253
thr_print_lock("read",&lock->read);
1254
thr_print_lock("read_wait",&lock->read_wait);
1255
VOID(pthread_mutex_unlock(&lock->mutex));
1259
pthread_mutex_unlock(&THR_LOCK_lock);
1262
1203
/*****************************************************************************
1263
1204
** Test of thread locks
1264
1205
****************************************************************************/