Article View: comp.unix.programmer
Article #12Messages between processes (how make it ??)
From: Lopi
Date: Wed, 28 Oct 1992 17:14
Date: Wed, 28 Oct 1992 17:14
41 lines
2074 bytes
2074 bytes
hello, I'm trying to write a program in which some processes exchange packets and messages, but I have 'some' difficulties... I would simulate a network, each process represents a machine and a particular process represents the net. I use pipes to let the machine communicate, who wants to send a packet puts it in the first pipe, the PipeMaster process gets it and puts it in a second pipe taking care that no two packets be in the second pipe at the same time, so , when he puts the packet in the pipe 2, he sends a signal to the destinationprocess ( kill(PID[dest],PACKET_SENT) ), when the destination gets the packet from the pipe , it sends a signal to the PipeMaster process ( kill(PipeMasterID, PACKET_RECEIVED) ) so that the PipeMaster can get another packet from the first pipe and put in the second, and so on... The main problem is the PID[] array and the PipeMasterID, which are the process id's, i.e. when i do ... pr = fork(); if(pr==0) Machine(i); PID[i++]=pr; ... the fork() duplicates the array so the child process doesn't know PID[j] for j>i .. so if PipeMaster() is `forked` before than the other machines, it doesn't know the other processes id, if it is forked as last, the other processes cannot signal the 'PACKET_RECEIVED' cause they don't know the PipeMaster id. My question is: Is there any easy way to let two processes communicate ? Any suggest is accepted... P.S. Please answer on this newsgroup, as I can't receive mail on my host. Thanks in Advance, Fabio Lopiano Dipartimento di Informatica Universita' di Pisa (Italy)
Technical Details
Message-ID:
<lopi.720292449@dipisa.di.unipi.it>Path:
arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!ghost.dsi.unimi.it!newsserver.di.unipi.it!lopiShow Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!ghost.dsi.unimi.it!newsserver.di.unipi.it!lopi From: lopi@di.unipi.it (Lopi) Subject: Messages between processes (how make it ??) Message-ID: <lopi.720292449@dipisa.di.unipi.it> Sender: netnews@di.unipi.it (USENET News System) Nntp-Posting-Host: dipisa.di.unipi.it Organization: Dipartimento di Informatica, Universita' di Pisa Date: Wed, 28 Oct 1992 17:14:09 GMT Lines: 41