Subject: Re: select call implementation and threads
To: malleswararao venkatanaga <bobbyavn@yahoo.com>
From: Andrey Petrov <petrov@netbsd.org>
List: tech-userlevel
Date: 05/27/2003 07:37:34
On Mon, May 26, 2003 at 02:41:27AM -0700, malleswararao venkatanaga wrote:
> Hi Andrey,
>   I'm using Pthread library which is available with
> netbsd 1.6
>   I'ld like to know which thread library you are using
> and are there any flags (extra) to be used while
> compilation.

pkg_info sais:
pth-1.4.1nb6        GNU Portable Thread library

and it was very standard installation. The machine is running 16K.
I wouldn't expect it to cause difference in behavouir though.

> Cuz even i've received messages on both the sockets
> incase the main thread is sent message first. But
> sometimes if i try sending messages to the other
> thread first and then the main thread wouldnot receive
> any. And mostly the behavior is non-deterministic. 
> 

I can't comment this because I can't reproduce it with
tests you sent.

	Andrey

> 
> thanks
> 
> --- Andrey Petrov <petrov@netbsd.org> wrote:
> > 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
> 
> 
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com