Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Regarding threads of different processes

2 views
Skip to first unread message

Gsec

unread,
Jul 26, 2006, 12:01:28 PM7/26/06
to
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 ?
If not, then my problem is solved. If they can communicate, then where
might be the problem
in my case ?

best regards,

Gaurav

Eric Sosman

unread,
Jul 26, 2006, 3:32:27 PM7/26/06
to

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 ...

--
Eric....@sun.com

Maxim Yegorushkin

unread,
Jul 26, 2006, 3:44:51 PM7/26/06
to

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.

Gsec

unread,
Jul 27, 2006, 1:43:44 AM7/27/06
to
Hi,
Thanks for the reply. My code segments go like this :

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

Maxim Yegorushkin

unread,
Jul 27, 2006, 3:41:27 AM7/27/06
to

May it be that ROOT thread has such a priority, that it starves A and B
threads?

0 new messages