Beispiel #1
0
void mq_initialize(void)
{
  /* Initialize the message free lists */

  sq_init(&g_msgfree);
  sq_init(&g_msgfreeirq);
  sq_init(&g_desalloc);

  /* Allocate a block of messages for general use */

  g_msgalloc =
    mq_msgblockalloc(&g_msgfree, CONFIG_PREALLOC_MQ_MSGS,
                     MQ_ALLOC_FIXED);

  /* Allocate a block of messages for use exclusively by
   * interrupt handlers
   */

  g_msgfreeirqalloc =
    mq_msgblockalloc(&g_msgfreeirq, NUM_INTERRUPT_MSGS,
                     MQ_ALLOC_IRQ);

  /* Allocate a block of message queue descriptors */

  mq_desblockalloc();
}
Beispiel #2
0
static mqd_t mq_desalloc(void)
{
    mqd_t mqdes;

    /* Try to get the message descriptorfrom the free list */

    mqdes = (mqd_t)sq_remfirst(&g_desfree);

    /* Check if we got one. */

    if (!mqdes)
    {
        /* Add another block of message descriptors to the list */

        mq_desblockalloc();

        /* And try again */

        mqdes = (mqd_t)sq_remfirst(&g_desfree);
    }

    return mqdes;
}