Subject: Re: select call implementation and threads
To: Andrey Petrov <petrov@netbsd.org>
From: malleswararao venkatanaga <bobbyavn@yahoo.com>
List: tech-kern
Date: 05/26/2003 02:41:27
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.
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. 


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