Altera_Forum
Honored Contributor
16 years agoMailboxes error in multicore system
Hi,
I have a 2-CPU system based on the NEEK, with two mailboxes (one for each CPU). One CPU send a 4-bytes message to the other, which displays it. The problem is that after that, the send and get functions returns the "EWOULDBLOCK" error code(-11) instead of 0, meaning that there is no messages or that the mailbox is full... Thank you to post your ideas!! Here are the code for the two CPUs: --- Quote Start --- int main() { alt_mailbox_dev* send_dev; alt_mailbox_dev* recv_dev; alt_u32 temp=0xabcd; //The message to send /* Open the two mailboxes between this processor and another */ recv_dev = altera_avalon_mailbox_open(MAILBOX_E1_NAME); send_dev = altera_avalon_mailbox_open(MAILBOX_O_NAME); while(1) { altera_avalon_mailbox_post(send_dev,temp); alt_busy_sleep(1000000); } return 0; } --- Quote End --- --- Quote Start --- int main() { int *err= malloc(sizeof(int)); alt_u32 temp=0x0; alt_mailbox_dev* recv_dev; alt_mailbox_dev* send_dev; /* Open the two mailboxes between this processor and another */ recv_dev = altera_avalon_mailbox_open(MAILBOX_O_NAME); send_dev = altera_avalon_mailbox_open(MAILBOX_E1_NAME); while(1) { printf("dans le while...\n"); temp= altera_avalon_mailbox_get(recv_dev,err); printf("check msg:%d\n",*err); if(*err==0x0) { printf(" %x\n",(int)temp); } printf("fall asleep..."); alt_busy_sleep(1000000); printf("and wake up..."); } return 0; } --- Quote End --- And what I get in result is: --- Quote Start --- dans le while... check msg:0 abcd fall asleep...and wake up...dans le while... check msg:-11 fall asleep...and wake up...dans le while... check msg:-11 fall asleep...and wake up...dans le while... check msg:-11 --- Quote End --- I am not sure, but I think that the problem comes from the sending CPU which terminates all by itself (surely just after posting the message into the mailbox), although there is a while(1) in the code! I see this just after the launching of the multiprocessor collection configuration: --- Quote Start --- <terminated>CPUE Nios II HW configuration [Nios II Hardware] <terminated, exit value: 0>Nios II Download output (12/10/09 10:00) --- Quote End --- Is there any clue to avoid this CPU to terminate in the middle of the launching?