Subject: Re: select call implementation and threads
To: malleswararao venkatanaga <bobbyavn@yahoo.com>
From: Andrey Petrov <petrov@netbsd.org>
List: tech-kern
Date: 05/24/2003 06:32:09
On Fri, May 23, 2003 at 09:50:02AM -0700, malleswararao venkatanaga wrote:
> Hi,
>  I'm facing a problem and it is somewhat like this,
>   1)I spawn a thread using pthread_create()
>   2) In the thread I open a socket, bind it to a port
> say 10001 and block it in the select call for
> receiving a UDP message.
>   Similarly 
>   In my main thread i open a socket and bind it to a 
> port say 10000 and block the main thread in a select
> call.
>   Both the main thread and the other thread are
> essentially waiting for different messages on
> different ports and different socket fds with their
> respective select calls.
>   I observe that if i send a messages to both of them
> only one of them receives while the other one is still
> blocked in the select call though it has messages to
> read. 
> 

Good thing about userland's threads is that it's easy to debug:
build pth library and your applicarion with '-g' and you'll
get the full picture of what's going on.

The behavouir you described is strange: select is normally
redefined to pth_select and that supposed to take care of swiching
betwean threads. Well, you can post your application here...

	Andrey