#4007 closed enhancement (fixed)

Add rtems_message_queue_construct()

Reported by: Sebastian Huber Owned by: Sebastian Huber
Priority: normal Milestone: 6.1
Component: rtems Version: 6
Severity: normal Keywords: qualification
Cc: Blocked By:
Blocking:

Description (last modified by Sebastian Huber)

In RTEMS 5 a lot of development was done to allow a static allocation of resources provided by RTEMS and avoid the use of a heap. Similar to #3959 a new directive to build Classic API message queues without using the workspace is proposed:

/**
 * @brief The message queue configuration to construct a message queue.
 */
typedef struct {
  /**
   * @brief The name of the message queue.
   */
  rtems_name name;

  /**
   * @brief The count of the provided buffers.
   *
   * This value defines the maximum number of pending messages.
   */
  size_t buffer_count;

  /**
   * @brief The size of the provided buffers in bytes.
   */
  size_t buffer_size;

  /**
   * @brief The array of count message buffers.
   *
   * Each buffer shall have the size of the buffer_size member.  The maximum
   * message size is buffer_size minus sizeof( rtems_message_queue_buffer ).
   */
  rtems_message_queue_buffer *buffers;

  /**
   * @brief The attribute set of the message queue.
   */
  rtems_attribute attributes;
} rtems_message_queue_config;

/**
 * @brief Constructs a message queue according to the specified configuration.
 *
 * @param config The message queue configuration.
 * @param[out] id The message queue identifier of the new message queue.
 *
 * @retval RTEMS_SUCCESSFUL Successful operation.
 * @retval RTEMS_INVALID_ADDRESS The id parameter is @c NULL.
 * @retval RTEMS_INVALID_NAME The message queue name is invalid.
 * @retval RTEMS_TOO_MANY No message queue is available.
 */
rtems_status_code rtems_message_queue_construct(
  const rtems_message_queue_config *config,
  rtems_id                         *id
);

Change History (16)

comment:1 Changed on 09/17/20 at 16:18:59 by Sebastian Huber

Description: modified (diff)
Status: assignedaccepted
Summary: Add rtems_message_queue_build()Add rtems_message_queue_construct()

comment:2 Changed on 09/17/20 at 16:19:28 by Sebastian Huber

Description: modified (diff)

comment:3 Changed on 09/28/20 at 05:17:56 by Sebastian Huber <sebastian.huber@…>

In 3c025576/rtems:

score: Use RTEMS_ALIGN_UP()

Update #4007.

comment:4 Changed on 09/28/20 at 05:17:59 by Sebastian Huber <sebastian.huber@…>

In fe2cb7c4/rtems:

score: Fix allocation size calculation

The previous multiplication error check is broken on 64-bit machines. Use the
recommended check from SEI CERT C Coding Standard, "INT30-C. Ensure that
unsigned integer operations do not wrap".

Make sure the message size computation does not overflow.

Update #4007.

comment:5 Changed on 09/28/20 at 05:18:03 by Sebastian Huber <sebastian.huber@…>

In 34dd90a5/rtems:

score: Gather message queue control initialization

Initialize the structure in a single code block after the error checks and
calculations.

Update #4007.

comment:6 Changed on 09/28/20 at 05:18:06 by Sebastian Huber <sebastian.huber@…>

In 5bc7c37/rtems:

score: Improve _CORE_message_queue_Initialize()

Return a status code and differentiate between error conditions.

Update #4007.

comment:7 Changed on 09/28/20 at 05:18:09 by Sebastian Huber <sebastian.huber@…>

In 69b4fe59/rtems:

score: Simplify CORE_message_queue_Buffer

Merge CORE_message_queue_Buffer structure into
CORE_message_queue_Buffer_control.

Use a zero-length array for the actual message buffer. This reduces the
structure size on all targets.

Update #4007.

comment:8 Changed on 09/28/20 at 05:18:13 by Sebastian Huber <sebastian.huber@…>

In 2c09f54f/rtems:

score: Add <rtems/score/coremsgbuffer.h>

Move the CORE_message_queue_Buffer definition to a separate header file to be
able to use it independent of the remaining Message Queue Handler API.

Change license to BSD-2-Clause according to file history.

Update #3053.
Update #4007.

comment:9 Changed on 09/28/20 at 05:18:16 by Sebastian Huber <sebastian.huber@…>

In 24ea1ce/rtems:

rtems: Remove Message_queue_Control::attribute_set

Add Message_queue_Control::is_global if RTEMS_MULTIPROCESSING is defined. This
reduces the Message_queue_Control size in standard RTEMS configurations.

Update #4007.

comment:10 Changed on 09/28/20 at 05:18:20 by Sebastian Huber <sebastian.huber@…>

In 4a4f41e/rtems:

rtems: Add rtems_message_queue_construct()

In contrast to message queues created by rtems_message_queue_create(), the
message queues constructed by this directive use a user-provided message buffer
storage area.

Add RTEMS_MESSAGE_QUEUE_BUFFER() to define a message buffer type for message
buffer storage areas.

Update #4007.

comment:11 Changed on 09/28/20 at 05:18:23 by Sebastian Huber <sebastian.huber@…>

In febc6604/rtems:

validation: Test rtems_message_queue_construct()

Update #4007.

comment:12 Changed on 04/23/21 at 06:25:29 by Sebastian Huber <sebastian.huber@…>

In 03747b50/rtems:

rtems: Check for NULL config in msgq construct

Since there are already excessive NULL pointer checks in the Classic
API, do this also in rtems_message_queue_construct().

Update #4007.

comment:13 Changed on 05/11/21 at 05:49:48 by Sebastian Huber <sebastian.huber@…>

In ab5aeb1/rtems:

score: Rename _Stack_Free_nothing()

Rename _Stack_Free_nothing() in _Objects_Free_nothing() to make it
reusable for the message queue buffers.

Update #4007.

comment:14 Changed on 05/11/21 at 05:49:51 by Sebastian Huber <sebastian.huber@…>

In c268766/rtems:

rtems: Use _Objects_Free_nothing() for msg queues

Use _Objects_Free_nothing() for rtems_message_queue_construct() to avoid
unreachable code in _CORE_message_queue_Close() in case only
user-provided message buffers are used.

Update #4007.

comment:15 Changed on 06/18/21 at 09:24:45 by Sebastian Huber

Keywords: qualification added

comment:16 Changed on 09/02/21 at 06:00:40 by Sebastian Huber

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.