[138] in Pthreads mailing list archive
Re: pthread.h : pthread_wait_data
daemon@ATHENA.MIT.EDU (Christopher Provenzano)
Thu Oct 12 05:53:21 1995
To: sudhir halbhavi <halbhavi@eecs.ukans.edu>
Cc: pthreads@MIT.EDU
In-Reply-To: Your message of "Sun, 08 Oct 1995 16:53:19 CDT."
<Pine.3.87.9510081618.A14414-0100000@mitchell>
Date: Thu, 12 Oct 1995 05:03:22 EDT
From: Christopher Provenzano <proven@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...).
>
> Sudhir
>
There are two reasons that it doesn't show up for all threads waiting
for some data.
1) This debugging feature was added after much of the thread blocking
features and we haven't gone back and fixed all those places.
2) I need to speed up the fast (default) mutexes which are currently too
slow so I don't feel that adding any code to this path is a good idea.
Some ideas are being worked on to fix this and have some reasonable
way of changeing between fast mutexes and mutexes with more debugging
info at runtime but nothing has been coded yet.
CAP