CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if you
use a link to a platform-specific file, simply state which one
(unless this isn't used in this case, e.g., with Microsoft Visual
C++)]:
CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
(used by MPC when you generate your own makefiles):
LEVEL OF URGENCY (LOW, MEDIUM, or HIGH):
HIGH
AREA/CLASS/EXAMPLE AFFECTED:
[What example failed? What module failed to compile?]
Please, see below for the source code.
DOES THE PROBLEM AFFECT:
COMPILATION?
LINKING?
On Unix systems, did you run make realclean first?
EXECUTION?
OTHER (please specify)?
[Please indicate whether ACE, your application, or both are affected.]
EXECUTION
SYNOPSIS:
[Brief description of the problem]
Program crashes.
DESCRIPTION:
[Detailed description of problem. Don't just say "<blah>
doesn't work, here's a fix," explain what your program does
to get to the <blah> state. ]
I'm trying to use a barrier with threads having arguments.
The program does not always work. Sometimes the program crashes.
REPEAT BY:
[What you did to get the error; include test program or session
transcript if at all possible. ]
class Args
{
public:
Args(ACE_Barrier *barrier, long i)
: barrier_(barrier)
, i_(i)
{
}
ACE_Barrier *barrier_;
long i_;
};
static void * worker(void *arguments)
{
Args *arg= (Args*)arguments;
ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work: %d\n", arg->i_));
::number++;
//Work
//ACE_OS::sleep(ACE_OS::rand()%2);
//Exiting now
ACE_DEBUG((LM_DEBUG,
"\tThread (%t) Done! \n\tThe number is now: %d\n",number));
//Let the barrier know we are done.
ACE_DEBUG((LM_DEBUG,"Thread (%t) is exiting \n"));
arg->barrier_->wait();
return 0;
}
int main(int argc, char *argv[])
{
if(argc<2)
{
ACE_DEBUG((LM_DEBUG,"Usage: <program_name> <number of threads>\n"));
ACE_OS::exit(1);
}
int n_threads=ACE_OS::atoi(argv[1]);
//ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads));
//Setup the random number generator
ACE_OS::srand(::seed);
//Spawn off n_threads number of threads
for(int i=0; i<n_threads; i++){ if(ACE_Thread::spawn((ACE_THR_FUNC)worker,(void*)&vect[i],THR_DETACHED|THR_ NEW_LWP)==-1)
ACE_DEBUG((LM_DEBUG,"Error in spawning thread\n"));
}
//Wait for all the other threads to let the main thread
// know that they are done using hte barrier
barrier.wait();
> CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if you
> use a link to a platform-specific file, simply state which one
> (unless this isn't used in this case, e.g., with Microsoft Visual
> C++)]:
> CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
> (used by MPC when you generate your own makefiles):
> LEVEL OF URGENCY (LOW, MEDIUM, or HIGH):
> HIGH
> AREA/CLASS/EXAMPLE AFFECTED:
> [What example failed? What module failed to compile?]
> Please, see below for the source code.
> DOES THE PROBLEM AFFECT:
> COMPILATION?
> LINKING?
> On Unix systems, did you run make realclean first?
> EXECUTION?
> OTHER (please specify)?
> [Please indicate whether ACE, your application, or both are affected.]
> EXECUTION
> SYNOPSIS:
> [Brief description of the problem]
> Program crashes.
> DESCRIPTION:
> [Detailed description of problem. Don't just say "<blah>
> doesn't work, here's a fix," explain what your program does
> to get to the <blah> state. ]
> I'm trying to use a barrier with threads having arguments.
> The program does not always work. Sometimes the program crashes.
> REPEAT BY:
> [What you did to get the error; include test program or session
> transcript if at all possible. ]
> SAMPLE FIX/WORKAROUND:
> [If available ]
> Source code:
Several questions:
1. Why are you using trying to use this ancient source code with ACE 6.0.4?
> class Args
> {
> public:
> Args(ACE_Barrier *barrier, long i)
> : barrier_(barrier)
> , i_(i)
> {
> }
> ACE_Barrier *barrier_;
> long i_;
> };
> static void * worker(void *arguments)
> {
> Args *arg= (Args*)arguments;
> ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work: %d\n", arg->i_));
> ::number++;
> //Work
> //ACE_OS::sleep(ACE_OS::rand()%2);
> //Exiting now
> ACE_DEBUG((LM_DEBUG,
> "\tThread (%t) Done! \n\tThe number is now: %d\n",number));
> //Let the barrier know we are done.
> ACE_DEBUG((LM_DEBUG,"Thread (%t) is exiting \n"));
> arg->barrier_->wait();
> return 0;
> }
> int n_threads=ACE_OS::atoi(argv[1]);
> //ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads));
> //Setup the random number generator
> ACE_OS::srand(::seed);
Barrier_Test has only one 'args' with parameters while the example I provided (let's say 'A') has four.
I tested 'A' with only one parameter with spawn_n and it works perfectly.
'A' has a call to barrier.wait() while Barrier_Test has a call to ACE_Thread_Manager::instance ()->wait ();
Thanks
Hubert ________________________________________ De : ace-users-boun...@list.isis.vanderbilt.edu [ace-users-boun...@list.isis.vanderbilt.edu] de la part de Douglas C. Schmidt [schm...@dre.vanderbilt.edu] Date d'envoi : 11 novembre 2012 11:38 À : Hubert Talbot Cc : ace-us...@list.isis.vanderbilt.edu Objet : Re: [ace-users] ACE_Barrier
> CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if you > use a link to a platform-specific file, simply state which one > (unless this isn't used in this case, e.g., with Microsoft Visual > C++)]:
> CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features > (used by MPC when you generate your own makefiles):
> LEVEL OF URGENCY (LOW, MEDIUM, or HIGH):
> HIGH
> AREA/CLASS/EXAMPLE AFFECTED: > [What example failed? What module failed to compile?]
> Please, see below for the source code.
> DOES THE PROBLEM AFFECT: > COMPILATION? > LINKING? > On Unix systems, did you run make realclean first? > EXECUTION? > OTHER (please specify)? > [Please indicate whether ACE, your application, or both are affected.]
> EXECUTION
> SYNOPSIS: > [Brief description of the problem]
> Program crashes.
> DESCRIPTION: > [Detailed description of problem. Don't just say "<blah> > doesn't work, here's a fix," explain what your program does > to get to the <blah> state. ]
> I'm trying to use a barrier with threads having arguments. > The program does not always work. Sometimes the program crashes.
> REPEAT BY: > [What you did to get the error; include test program or session > transcript if at all possible. ]
> SAMPLE FIX/WORKAROUND: > [If available ]
> Source code:
Several questions:
1. Why are you using trying to use this ancient source code with ACE 6.0.4?
> class Args > { > public: > Args(ACE_Barrier *barrier, long i) > : barrier_(barrier) > , i_(i) > { > } > ACE_Barrier *barrier_; > long i_; > };
> static void * worker(void *arguments) > { > Args *arg= (Args*)arguments; > ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work: %d\n", arg->i_)); > ::number++;
> //Work > //ACE_OS::sleep(ACE_OS::rand()%2);
> //Exiting now > ACE_DEBUG((LM_DEBUG, > "\tThread (%t) Done! \n\tThe number is now: %d\n",number)); > //Let the barrier know we are done. > ACE_DEBUG((LM_DEBUG,"Thread (%t) is exiting \n")); > arg->barrier_->wait(); > return 0; > }
> int n_threads=ACE_OS::atoi(argv[1]); > //ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads)); > //Setup the random number generator > ACE_OS::srand(::seed);
> Barrier_Test has only one 'args' with parameters while the example I provided (let's say 'A') has four.
> I tested 'A' with only one parameter with spawn_n and it works perfectly.
> 'A' has a call to barrier.wait() while Barrier_Test has a call to ACE_Thread_Manager::instance ()->wait ();
> Thanks
> Hubert
> ________________________________________
> De : ace-users-boun...@list.isis.vanderbilt.edu [ace-users-boun...@list.isis.vanderbilt.edu] de la part de Douglas C. Schmidt [schm...@dre.vanderbilt.edu]
> Date d'envoi : 11 novembre 2012 11:38
> À : Hubert Talbot
> Cc : ace-us...@list.isis.vanderbilt.edu
> Objet : Re: [ace-users] ACE_Barrier
> Hi Hubert,
> Thanks for using the PRF.
> > ACE VERSION: 6.0.4
> > HOST MACHINE and OPERATING SYSTEM:
> > Windows 7
> > TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
> > COMPILER NAME AND VERSION (AND PATCHLEVEL):
> > CONTENTS OF $ACE_ROOT/ace/config.h [if you use a link to a platform-
> > specific file, simply state which one]:
> > CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if you
> > use a link to a platform-specific file, simply state which one
> > (unless this isn't used in this case, e.g., with Microsoft Visual
> > C++)]:
> > CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
> > (used by MPC when you generate your own makefiles):
> > LEVEL OF URGENCY (LOW, MEDIUM, or HIGH):
> > HIGH
> > AREA/CLASS/EXAMPLE AFFECTED:
> > [What example failed? What module failed to compile?]
> > Please, see below for the source code.
> > DOES THE PROBLEM AFFECT:
> > COMPILATION?
> > LINKING?
> > On Unix systems, did you run make realclean first?
> > EXECUTION?
> > OTHER (please specify)?
> > [Please indicate whether ACE, your application, or both are affected.]
> > EXECUTION
> > SYNOPSIS:
> > [Brief description of the problem]
> > Program crashes.
> > DESCRIPTION:
> > [Detailed description of problem. Don't just say "<blah>
> > doesn't work, here's a fix," explain what your program does
> > to get to the <blah> state. ]
> > I'm trying to use a barrier with threads having arguments.
> > The program does not always work. Sometimes the program crashes.
> > REPEAT BY:
> > [What you did to get the error; include test program or session
> > transcript if at all possible. ]
> > SAMPLE FIX/WORKAROUND:
> > [If available ]
> > Source code:
> Several questions:
> 1. Why are you using trying to use this ancient source code with ACE 6.0.4?
> > int n_threads=ACE_OS::atoi(argv[1]);
> > //ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads));
> > //Setup the random number generator
> > ACE_OS::srand(::seed);
> Here is an enhanced Barrier_Test.cpp from ACE 6.1.6; the behaviour was the same with version 6.0.4.
> However, I found my problem.
> In the code provided with the PRF, it happens that one Args object is destroyed before the thread terminates. In the enhanced version of Barrier_Test.cpp, objects are created dynamically and deleted at the end of the thread. This fixes the problem.
> I don't know if the enhanced Barrier_Test.cpp can be useful now...
> Sorry for the inconvenience.
> Thanks.
> Hubert
> -----Message d'origine-----
> De : schm...@dre.vanderbilt.edu [mailto:schm...@dre.vanderbilt.edu]
> Envoyé : 11 novembre 2012 18:21
> À : Hubert Talbot
> Cc : ace-us...@list.isis.vanderbilt.edu
> Objet : Re: RE : [ace-users] ACE_Barrier
> Hi Hubert,
> Could you please enhance the the ACE_ROOT/tests/Barrier_Test.cpp regression test in 6.0.4 so that it manifests the problem that you're having?
> Thanks,
> Doug
>> Thank you for the time you give me.
>> The two examples are slightly different.
>> Barrier_Test has only one 'args' with parameters while the example I provided (let's say 'A') has four.
>> I tested 'A' with only one parameter with spawn_n and it works perfectly.
>> 'A' has a call to barrier.wait() while Barrier_Test has a call to
>> ACE_Thread_Manager::instance ()->wait ();
>> Thanks
>> Hubert
>> ________________________________________
>> De : ace-users-boun...@list.isis.vanderbilt.edu
>> [ace-users-boun...@list.isis.vanderbilt.edu] de la part de Douglas C.
>> Schmidt [schm...@dre.vanderbilt.edu] Date d'envoi : 11 novembre 2012
>> 11:38 À : Hubert Talbot Cc : ace-us...@list.isis.vanderbilt.edu
>> Objet : Re: [ace-users] ACE_Barrier
>> Hi Hubert,
>> Thanks for using the PRF.
>>> ACE VERSION: 6.0.4
>>> HOST MACHINE and OPERATING SYSTEM:
>>> Windows 7
>>> TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
>>> COMPILER NAME AND VERSION (AND PATCHLEVEL):
>>> CONTENTS OF $ACE_ROOT/ace/config.h [if you use a link to a platform-
>>> specific file, simply state which one]:
>>> CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU [if you
>>> use a link to a platform-specific file, simply state which one
>>> (unless this isn't used in this case, e.g., with Microsoft Visual
>>> C++)]:
>>> CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
>>> (used by MPC when you generate your own makefiles):
>>> LEVEL OF URGENCY (LOW, MEDIUM, or HIGH):
>>> HIGH
>>> AREA/CLASS/EXAMPLE AFFECTED:
>>> [What example failed? What module failed to compile?]
>>> Please, see below for the source code.
>>> DOES THE PROBLEM AFFECT:
>>> COMPILATION?
>>> LINKING?
>>> On Unix systems, did you run make realclean first?
>>> EXECUTION?
>>> OTHER (please specify)?
>>> [Please indicate whether ACE, your application, or both are
>>> affected.]
>>> EXECUTION
>>> SYNOPSIS:
>>> [Brief description of the problem]
>>> Program crashes.
>>> DESCRIPTION:
>>> [Detailed description of problem. Don't just say "<blah> doesn't
>>> work, here's a fix," explain what your program does to get to the
>>> <blah> state. ]
>>> I'm trying to use a barrier with threads having arguments.
>>> The program does not always work. Sometimes the program crashes.
>>> REPEAT BY:
>>> [What you did to get the error; include test program or session
>>> transcript if at all possible. ]
>>> SAMPLE FIX/WORKAROUND:
>>> [If available ]
>>> Source code:
>> Several questions:
>> 1. Why are you using trying to use this ancient source code with ACE 6.0.4?
>>> class Args
>>> {
>>> public:
>>> Args(ACE_Barrier *barrier, long i)
>>> : barrier_(barrier)
>>> , i_(i)
>>> {
>>> }
>>> ACE_Barrier *barrier_;
>>> long i_;
>>> };
>>> static void * worker(void *arguments) {
>>> Args *arg= (Args*)arguments;
>>> ACE_DEBUG((LM_DEBUG,"Thread (%t) Created to do some work: %d\n", arg->i_));
>>> ::number++;
>>> //Work
>>> //ACE_OS::sleep(ACE_OS::rand()%2);
>>> //Exiting now
>>> ACE_DEBUG((LM_DEBUG,
>>> "\tThread (%t) Done! \n\tThe number is now: %d\n",number));
>>> //Let the barrier know we are done.
>>> ACE_DEBUG((LM_DEBUG,"Thread (%t) is exiting \n"));
>>> arg->barrier_->wait();
>>> return 0;
>>> }
>>> int n_threads=ACE_OS::atoi(argv[1]);
>>> //ACE_DEBUG((LM_DEBUG,"Preparing to spawn %d threads",n_threads));
>>> //Setup the random number generator
>>> ACE_OS::srand(::seed);