From fnaumann@mail.cs.uni-magdeburg.de Tue Sep 14 17:29:29 2004 Message-ID: <41470D08.5050804@utbm.fr> Date: Tue, 14 Sep 2004 17:23:52 +0200 From: Olivier Landemarre User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ingo Schmidt , MiNT-Liste Subject: Re: [MiNT] Pmsg() usage References: <41419C3C.6080002@utbm.fr> <446220110.20040911203225@der-ingo.de> In-Reply-To: <446220110.20040911203225@der-ingo.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=0.0 required=6.0 tests=BAYES_50 autolearn=no version=2.64 X-Spam-Level: Score: X-Spam-Checker-Version: SpamAssassin 2.64 (2004-01-11) on portail1.utbm.fr Delivered-To: mint@fishpool.com Delivered-To: mint@lists.fishpool.fi X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: olivier.landemarre@utbm.fr Precedence: bulk List-help: List-unsubscribe: List-ID: X-List-ID: X-Milter: ClamAV 0.70/0.70kjel X-Milter: milter-regex 1.5jel X-Milter: ClamAV 0.70/0.70kjel X-Milter: milter-regex 1.5jel Ingo Schmidt wrote: >Hi! > >OL> I have 2 programs one is something like this: > >I use pmsg in exactly that situation and it works fine for me. I guess >you want to synchronize two processes with that, right? > >Out of my experience the best way is to always use 0xffff0000+my_pid >as mailbox id for receiving messages and 0xffff0000+receiver_pid as >mailbox id for sending. An example: >There are two processes, A and B with pids 1 and 2. >Now lets do your scenario: > >Program A has this code: >pmsg(0,0xffff0001,&r); >printf("A: message received\n"); >printf("A: Sending message..."); >pmsg(1,0xffff0002,&r); >printf("OK\n"); >Pterm(); > >Program B has this code: >pmsg(2,0xffff0001,&r); >printf("B: message received\n"); >Pterm(); > >Now start program A and then program B and everything will work fine. > >Also consider that in pmsg mode 2 the mailbox id for sending and >receiving are usually different (unless you use mailbox IDs like >described above). > >I hope this helped. > > Yes a lot, now it work! Thanks Now I have an other problem with Pmsg() and I think it's a bug of Mint. Here example Suppose id=1 for a server and 2 clients id=2 and 3 Server is waiting with Pmsg(0,1,&r); Then client 2 and 3 decide to send message to server simultaneously, so before server have to do something there is 2 message with Pmsg(2,1,&r2); /* client 2 */ Pmsg(2,1,&r3); /* client 3 */ So server receive message from 2 do what it have to do and send answer: Pmsg(1,2|0xFFFF0000,&r); /* the answer of client 2 is good the 2 long value are correct value */ the server so do an other Pmsg(0,1,&r); so it receive the message from client 3 do what it have to do, all is ok put value in r then send message to 3 with: Pmsg(1,3|0xFFFF0000,&r); So client 3 receive answer UNFORTUNATLY long values in r3 are not modify so it's wrong, so for me there is a bug. If I wait answer before accept send a new message with a semaphore all is Ok. Olivier