[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Pmsg() usage



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.

Cheers, Ingo =;->