I have a question. I have one process, that spawns two threads, say,
A,B.
Now, after spawning these two threads, I did some
applications(downloading a file). Everything is going fine.
After the application is over, I have created another task , which will
spawn 10 different
threads ,say, P1,P2....,P10.
Now, when I try to send an event from P1 to A, A is not getting the
event at all !
Now, my doubt is can two different threads of two different parents can
communicate ?
If not, then my problem is solved. If they can communicate, then where
might be the problem
in my case ?
best regards,
Gaurav
Gsec wrote On 07/26/06 12:01,:
> Hi,
>
> I have a question. I have one process, that spawns two threads, say,
> A,B.
>
> Now, after spawning these two threads, I did some
> applications(downloading a file). Everything is going fine.
>
> After the application is over, I have created another task , which will
> spawn 10 different
> threads ,say, P1,P2....,P10.
>
> Now, when I try to send an event from P1 to A, A is not getting the
> event at all !
>
> Now, my doubt is can two different threads of two different parents can
> communicate ?
Yes, but only by using the techniques through which
different processes can communicate: pipes, sockets, shared
memory segments, the file system, signals, ... All the
interprocess communication mechanisms are available for use
by both single- and multi-threaded processes.
> If not, then my problem is solved. If they can communicate, then where
> might be the problem
> in my case ?
Probably in the way you "send an event" from P1 to A,
or in the way A "receives an event" from P1 ...
Threads of different processes can communicate. You have to use most
suitable for you means of interprocess communcations (ipc): signals,
semaphores, file, pipe, fifo, tcp/udp/unix sockets, shared memory,
message queues, doors.
void SimMain ( )
{
Do_Handshaking( ); /* This function does a unix domain
socket communication to a server . After the initial hanshking is done,
do create two threads, A and B*/
create thread A( Send ); /* "Send" is the entry point
function for this thrd */
create thread B (Recv); /*Recv is the entry pt for this
thrd */
}
void Send ( )
{
FOEVER ( )
{
if (RecvEvent ( ) != SUCCESS )
continue;
if (RecvFromQ ( )!= SUCCESS )
continue;
..............
.............
}
}
Then I spawn another thread "ROOT" with priority 0, which inturn will
spawn 24 threads.
But, the problem is now is that until the ROOT thread is not spwaned,
the SEND ( ) function is working properly, recieving events and msgs
from Q s properly.
Once the ROOT thread spwaned, the SEND ( ) function is not all working,
even, a printf inside the FOREVER, before recvevent isn't printing at
all!
I checked, if the SEND and RECV threads are exited, or some address is
corrupted. But, all are fine !
Now, any more clue ?
-Gsec
May it be that ROOT thread has such a priority, that it starves A and B
threads?