Subject: Re: select call implementation and threads
To: malleswararao venkatanaga <bobbyavn@yahoo.com>
From: Andrey Petrov <petrov@netbsd.org>
List: tech-userlevel
Date: 05/25/2003 20:42:55
On Sun, May 25, 2003 at 01:24:40AM -0700, malleswararao venkatanaga wrote:
> 
> --- Andrey Petrov <petrov@netbsd.org> wrote:
> > On Sat, May 24, 2003 at 04:26:11AM -0700,
> > malleswararao venkatanaga wrote:
> > > Here is the code i tested with.
> > > /* Recv.c This is the code that receives messages
> > */
> > > #include <stdio.h>
> > > #include<fcntl.h>
> > > #include<errno.h>
> > > #include<sys/types.h>
> > > #include<sys/select.h>
> > > #include<sys/socket.h>
> > > #include<netinet/in.h>
> > > #include <pthread.h>
> > > 
> > > void * stub_test (void *p );
> > > pthread_t  threads[3];
> > > int main()
> > > {
> > >   int rc;
> > >   stub_test2();
> > >   rc = pthread_create(&threads[0], NULL ,
> > stub_test
> > > ,(void *) &threads[0]);
> > 
> > Well, well, well. Try to reverse 2 previous lines.
> > 
> Hi Andrey,
> I've reversed the above 2 lines. But i still get 
> non-deterministic results, one of the threads gets
> blocked and never comes out of the select call though
> it has messages to read.
> 

I tried it myself and both threads receive messages,
ehm 'works for me'. At this point I'd recommend you
to use debugger to find out where your problem is.

	Andrey