Keil Logo

External References

The semaphore and mailbox objects are referenced by the RTX kernel as typeless object pointers and are typecast inside the specific RTX kernel module. For semaphores and task handles, this is not a problem. The problem is when referencing the mailbox, which is declared using the macro os_mbx_declare(). That is why the OS_MBX type is defined. You have to use the OS_MBX object type identifier to reference mailboxes in external modules.

Here is an example of how the external RTX kernel objects are referenced:

extern OS_TID tsk1;
extern OS_SEM semaphore1;
extern OS_MUT mutex1;
extern OS_MBX mailbox1;

The following example shows you how to make a reference to a mailbox from a different C-module.

  • C-Module with a mailbox1 declaration:
    #include <rtl.h>
    
    os_mbx_declare (mailbox1, 20);
    
    __task void task1 (void) {
      void *msg;
    
      os_mbx_init (mailbox1, sizeof (mailbox1));
      msg = alloc();
      /* set message content here */
      os_mbx_send (mailbox1, msg);
       ..
    }
    
  • C-Module with a mailbox1 reference:
    #include <RTL.h>
    
    extern OS_MBX mailbox1;
    
    __task void task2 (void) {
      void *msg;
       ..
      os_mbx_wait (mailbox1, &msg, 0xffff);
      /* process message content here */
      free (msg);
       ..
    }
    
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.