Home > Archive > Unix Programming > July 2006 > Regarding threads of different processes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Regarding threads of different processes
|
|
|
| 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 2006-07-26, 7:01 pm |
|
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.Sosman@sun.com
| |
| Maxim Yegorushkin 2006-07-26, 7:01 pm |
|
Gsec wrote:
> 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 ?
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.
| |
|
| 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 wrote:
> Gsec wrote:
>
> 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.
| |
| Maxim Yegorushkin 2006-07-27, 4:00 am |
| Gsec wrote:
> 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 ?
May it be that ROOT thread has such a priority, that it starves A and B
threads?
|
|
|
|
|