<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=671311302-23092008><FONT face=Arial
color=#0000ff size=2>If compiling with -g causes it to fail, there is probably
some race condition in your program.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=671311302-23092008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=671311302-23092008><FONT face=Arial
color=#0000ff size=2>Rajeev</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> owner-mpich-discuss@mcs.anl.gov
[mailto:owner-mpich-discuss@mcs.anl.gov] <B>On Behalf Of </B>Gisele Machado de
Souza<BR><B>Sent:</B> Monday, September 22, 2008 3:49 PM<BR><B>To:</B>
mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> Re: [mpich-discuss] Multithread
server using MPICH-2<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>People, help me. <BR>Like I said in my previous message, my
application worked when I compile the library with the
options:<BR><BR>./configure --enable-romio --without-mpe --with-pm=mpd
--with-device=ch3:sock --enable-threads=multiple --with-thread-package=posix
<BR><BR>I did a safe copy of the version that is working. <BR><BR>But when I
test remove all .o and executable files, and compile again, the
application stops working.<BR>(and my safe copy is working)<BR><BR>In my
makefile I put:<BR><BR>CFLAGS = -g<BR>CLIBS = -lpthread -lm<BR><BR>I need to
compile with more options to make it work?<BR><BR>
<DIV class=gmail_quote>2008/9/19 Gisele Machado de Souza <SPAN dir=ltr><<A
href="mailto:giselemachad@gmail.com"
target=_blank>giselemachad@gmail.com</A>></SPAN><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV dir=ltr>People, thank you all!!!<BR>I find a solution. I used
mpich2-1.0.7 and compiled with this options:<BR><BR>> ./configure
--enable-romio --without-mpe --with-pm=mpd --with-device=ch3:sock
--enable-threads=multiple --with-thread-package=posix <BR><BR>and I
included this instructions from phtreads:<BR><BR>>
pthread_attr_init(&attr);<BR>
pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_DETACHED);<BR> rc =
pthread_create(&threads[t], &attr, threadfunc, (void *)
listParam);<BR><BR>It works!!!<BR><BR>
<DIV dir=ltr>I hope not have more problems and I hope that the library is
really stable for this type of situation.<BR><BR>If I have any other problem
I turn to send messages. <BR>Thank you for
helping!!!!<BR><BR></DIV><BR><BR><BR><BR><BR>
<DIV class=gmail_quote>2008/9/19 Rajeev Thakur <SPAN dir=ltr><<A
href="mailto:thakur@mcs.anl.gov"
target=_blank>thakur@mcs.anl.gov</A>></SPAN>
<DIV>
<DIV></DIV>
<DIV><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>Can
you send us a small test case to reproduce the
problem?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2>Rajeev</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,255) 2px solid; MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:owner-mpich-discuss@mcs.anl.gov"
target=_blank>owner-mpich-discuss@mcs.anl.gov</A> [mailto:<A
href="mailto:owner-mpich-discuss@mcs.anl.gov"
target=_blank>owner-mpich-discuss@mcs.anl.gov</A>] <B>On Behalf Of
</B>Gisele Machado de Souza<BR><B>Sent:</B> Thursday, September 18, 2008
11:04 PM<BR><B>To:</B> <A href="mailto:mpich-discuss@mcs.anl.gov"
target=_blank>mpich-discuss@mcs.anl.gov</A><BR><B>Subject:</B>
[mpich-discuss] Multithread server using MPICH-2<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<DIV></DIV>
<DIV dir=ltr>Hello,<BR><BR>I'm implementing a server in MPI that accepts
more than one connection from clients at the same time.<BR>For do that I
used MPI(mpich2-1.1.0a1.tar.gz) and pthreads.<BR><BR>What I want to do
is a server that stays in a infinity loop waiting for connections
(MPI_Comm_accept(portMD, MPI_INFO_NULL, 0, MPI_COMM_WORLD,
newCommClient);). When a connection is established, he creates a new
thread and return to wait more connections. That means, the server
and the thread will work in parallel.<BR><BR>The function that the
thread will execute calls mpi functions, like MPI_probe, MPI_Get_count,
MPI_Recv, MPI_Send, MPI_Pack and MPI_Unpack.<BR><BR>The
problem I'm having is that the server and the thread are not working in
parallel successfully. Sometimes, the program hangs, do nothing, and in
another times a fatal error appears (Assertion failed in file
sock_wait.i at line 236: (pollfd->events & (0x001 | 0x004)) ||
pollfd->fd == -1).<BR><BR>When I put the server to sleep for a
moment, before he will wait another connection, during the time he was
sleeping the created thread works fine. Once the server wakes up and
starts to wait for a connection, things stop working.<BR><BR>A peace of
my code
(Server):<BR>-----------------------------------------------------------------------------------------------------------------------------<BR>//
arguments passed to a thread<BR>typedef struct<BR>{ MPI_Comm
communicator;<BR> char * path1;<BR> char * path2;<BR>
char * port; <BR>} ThreadParam;<BR><BR> pthread_t
threads[10];<BR> int t =0;<BR> int
rc;<BR><BR><BR> ThreadParam * listParam = NULL;<BR> MPI_Comm *
newCommClient;<BR> <BR><BR> /* server
infinity loop */<BR> while (time_out >
10)<BR> {<BR> <BR>
newCommClient = malloc(sizeof(MPI_Comm));<BR>
<BR> <BR> /* waiting for a
connection */<BR> MPI_Comm_accept(portMD,
MPI_INFO_NULL, 0, MPI_COMM_WORLD,
newCommClient);<BR>
<BR> listParam =
malloc(sizeof(ThreadParam));
<BR> listParam->communicator =
*newCommClient; //with this communicator the thread will talk with
the
/
//client <BR> listParam->path1 =
argv[2];<BR> listParam->path2 =
argv[4];<BR> listParam->port =
portMD;<BR> <BR> rc =
pthread_create(&threads[t], NULL, threadfunc, (void *)
listParam);<BR> <BR> if
(rc){<BR> printf("ERROR;
return code from pthread_create() is %d\n",
rc);<BR>
exit(-1);<BR> }<BR>
//sleep(1); <BR> t++;<BR>
}<BR><BR>-----------------------------------------------------------------------------------------------------------------------------<BR>Please,
I need help to solve this problem!!<BR><BR>Thanks very
mych!<BR><BR>Gisele<BR></DIV></DIV></DIV></BLOCKQUOTE></DIV></BLOCKQUOTE></DIV></DIV></DIV><BR></DIV></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>