As per my project requirement, I am evaluating smartfusion device with RTX in A2F-EVAL-KIT. I see Keil RTX has something called mailbox, which i am particularly interested in. I tried to create and build program using mailbox as per below link In simulated HW env things worked out great. http://www.keil.com/support/man/docs/rlarm/rlarm_ar_mbx_using.htm
But when i use the same source to build program in eval board, It is not working as expected from simulated env.
__task void send_task (void) { /* This task will send a message. */ U32 *mptr;
os_tsk_create (rec_task, 0); os_mbx_init (MsgBox, sizeof(MsgBox)); mptr = _alloc_box (mpool); /* Allocate a memory for the message */ mptr[0] = 0x3215fedc; /* Set the message content. */ mptr[1] = 0x00000015; os_mbx_send (MsgBox, mptr, 0xffff); /* Send a message to a 'MsgBox' */ os_tsk_delete_self (); }
os_mbx_send in above sniffet gets blocked [Goes to sleep] for ever. I know if i pass argument 0xffff to os_mbx_send it is suppose to wait indefinitely. But i see the same behaviour in other timeout values e.g 3 (clock ticks). Since this is the first insertion made to mailbox as per mailbox demo program in above link, it shouldn't matter. i dont get it why there is different behaviour in simulated Hw/Actual Hw (Eval board).
Is this a bug in Keil MDK (RTX) ?
Any help appreciated ...
Where is the code?
Or did you *oops* forget to read the instructions on how to post source code? And forgot to consider the obligatory preview? Take a look directly above the message input box. "Place source code [...]"
Or the link "Tips for Posting Messages".
source code is in link provided. I have just created a new RTX project and pasted what is there in refered link. For ur ease i repeat the same again below. After the control reach function call "os_mbx_send" in "rec_task", it goes to sleep, neither there is any task switch to "rec_task" (probably tsk_lock called in os_mbx_send).
Its funny to see the same working properly in Simulated Hw.
http://www.keil.com/support/man/docs/rlarm/rlarm_ar_mbx_using.htm
#include <rtl.h> os_mbx_declare (MsgBox, 16); /* Declare an RTX mailbox */ U32 mpool[16*(2*sizeof(U32))/4 + 3]; /* Reserve a memory for 16 messages */ __task void rec_task (void); __task void send_task (void) { /* This task will send a message. */ U32 *mptr; os_tsk_create (rec_task, 0); os_mbx_init (MsgBox, sizeof(MsgBox)); mptr = _alloc_box (mpool); /* Allocate a memory for the message */ mptr[0] = 0x3215fedc; /* Set the message content. */ mptr[1] = 0x00000015; os_mbx_send (MsgBox, mptr, 0xffff); /* Send a message to a 'MsgBox' */ os_tsk_delete_self (); } __task void rec_task (void) { /* This task will receive a message. */ U32 *rptr, rec_val[2]; os_mbx_wait (MsgBox, &rptr, 0xffff); /* Wait for the message to arrive. */ rec_val[0] = rptr[0]; /* Store the content to 'rec_val' */ rec_val[1] = rptr[1]; _free_box (mpool, rptr); /* Release the memory block */ os_tsk_delete_self (); } void main (void) { _init_box (mpool, sizeof(mpool), sizeof(U32)); os_sys_init(send_task); }
Sorry my bad. It should be
After the control reach function call "os_mbx_send" in "send_task" , it goes to sleep, neither there is any task switch to "rec_task" (probably tsk_lock called in os_mbx_send).
I don't much like programs that creates tasks before all required infrastructure have been initialized:
os_tsk_create (rec_task, 0); os_mbx_init (MsgBox, sizeof(MsgBox));
Note that if the OS switches to rec_task directly, then you haven't initialized MsgBox. And rec_task expects msgBox to be valid.
I understand your concern. I also tried in reverse order but getting into same problem finally [GOING TO SLEEP FOR EVER while performing os_mbx_send, Blocking tsk switching].
os_mbx_init (MsgBox, sizeof(MsgBox)); os_tsk_create (rec_task, 0);