[134] in Pthreads mailing list archive
pthread.h : pthread_wait_data
daemon@ATHENA.MIT.EDU (sudhir halbhavi)
Sun Oct 8 18:22:54 1995
Date: Sun, 8 Oct 1995 16:53:19 -0500 (CDT)
From: sudhir halbhavi <halbhavi@eecs.ukans.edu>
To: pthreads@MIT.EDU
Hi,
I am trying to understand hows and whys of some data structures.
I have a question regarding the above data structure.
file "pthread.h"
union pthread_wait_data {
pthread_mutex_t * mutex;
pthread_cond_t * cond;
const sigset_t * sigwait; /* Waiting on a signal in sigwait */
struct {
short fd; /* Used when thread waiting on fd */
short branch; /* line number, for debugging */
} fd;
struct pthread_select_data * select_data;
};
From the documentation in the pthread structure....
/*
* Standard link list for running threads, mutexes, etc ...
* It can't be on both a running link list and a wait queue.
* Must lock kernel lock before manipulating.
*/
struct pthread * next;
union pthread_wait_data data;
I wrote a simple program, with threads accessing a mutex.
I find that "next" points to the next thread waiting on the corresponding
mutex, but the union itself does not show any pointer (shows only null
pointers). It would seem to me that it should point to the mutex on which
it is waiting (or a condition var or a fd...).
Shown below is what I find. Thanks for any input.
Sudhir
*****************************************************************
(gdb) ls-t
Number of threads = 6
Thread_pointer = 0x16978 (92536), Thread_id = 1
Thread_pointer = 0x16d78 (93560), Thread_id = 2
Thread_pointer = 0x16f78 (94072), Thread_id = 3
Thread_pointer = 0x17178 (94584), Thread_id = 4
Thread_pointer = 0x17378 (95096), Thread_id = 5
Thread_pointer = 0x17578 (95608), Thread_id = 6 ****
(gdb) ls-mutex test_mutex
Owner of mutex = 0x16978 ******
Threads waiting on mutex "test_mutex"
Thread_ptr = 0x16d78
thread_ptr = 0x16f78
thread_ptr = 0x17178
thread_ptr = 0x17378
(gdb) p *pthread_link_list->pll->pll->pll->pll
$22 = {machdep_data = {start_routine = 0x10c8 <lock_mutex>,
start_argument = 0x0, machdep_stack = 0x25978, machdep_timer = {
it_interval = {tv_sec = 0, tv_usec = 0}, it_value = {tv_sec = 0,
tv_usec = 100000}}, machdep_state = {{__bx = 26, __si = 93588,
__di = 0, __bp = 0x358f8, __sp = 0x358f4, __pc = 0x54f5}},
machdep_float_state = "r\0\0", '\000' <repeats 14 times>,", '\000'
<repeats 31 times>,
"\220\000\000\000\000\000\200~?\000\000\000\000\000\000\000\200~?",
'\000' <repeats 29 times>}, attr = {
schedparam_policy = SCHED_RR, prio = 64, flags = 0, arg_attr = 0x0,
cleanup_attr = 0, stackaddr_attr = 0x0, stacksize_attr = 65536},
__sigmask = 0, sigpending = 0, sigcount = 0, wakeup_time = {ts_sec = 0,
ts_nsec = 0}, join_queue = {q_next = 0x0, q_last = 0x0, q_data =
0x0},
pll = 0x16978, next = 0x16f78, data = {mutex = 0x0, cond = 0x0,
sigwait = 0x0, fd = {fd = 0, branch = 0}, select_data = 0x0},
queue = 0x1434c, state = PS_MUTEX_WAIT, flags = 0 '\000',
pthread_priority = 64 '@', sll = 0x0, ret = 0x0, error = 0, error_p =
0x0,
specific_data = 0x0, specific_data_count = 0, cleanup = 0x0}