Hi all,
I have multithreaded com application in which i have one parent threads
which create child threads.
The parent thread allocates some memory and the child threads work on the
same memory all at the same time (this is a mem stress test program).
For the synchronization between parent and child threads I have array of
events in Parent threads.
GoAhead[} and DoneWithMemory.
pseudo code for parent is as
{
while(!terminate)
{
get the memory
Set the the GoAhead events for each thread.
//(this event are auto reset and initially are in reset state.)
WaitForMultiplleObject(no of threads, DoneWithMemory,
Infinite);
release memory
}
Set Go Ahead for all the threads
//(this is to release the child threads from wait in case of terminate from
user)
}
The child pseudo code is as
while(!terminate)
{
WaitFor (GoAhead)
Operate on memory…
Set Done With memory.
}
(Right now I am testing with only one child thread)
My problems are
-
Sometime the pointer in Child thread is Null before i start working with
the memory.
I have error check for null pointer and my application exits. -
When i stop my application my child thread is still waiting for GoAhead
event though i am setting Goahead event when user selects to terminate.
The problem is very strange…Both the above mentioned problem comes only
when i run them with specific test configurations… (i have other test also
running with this test which again are all multithreaded)
Could any one tell me is there any loop hole in my logic of synchronization
of the parent child threads.
None of the apis I am using are failing due to any reason.
I couldnt make out the real problem, whether its due to timing problem, or
curroption of any handles or something like that, which cause my apis to
behave strangly.
Any comments will be of great help.
Thanx for reading this long mail.
Regards,
Manish