source: rtems/cpukit/rtems/src/msgqdelete.c @ d78d529

5
Last change on this file since d78d529 was 0e1d11f3, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 11:26:53

score: Add _Thread_queue_Context_set_MP_callout()

Add _Thread_queue_Context_set_MP_callout() to simplify
_Thread_queue_Context_initialize(). This makes it possible to more
easily add additional fields to Thread_queue_Context.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Delete Message Queue
5 *  @ingroup ClassicMessageQueue
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/messageimpl.h>
22#include <rtems/rtems/attrimpl.h>
23
24rtems_status_code rtems_message_queue_delete(
25  rtems_id id
26)
27{
28  Message_queue_Control *the_message_queue;
29  Thread_queue_Context   queue_context;
30
31  _Objects_Allocator_lock();
32  the_message_queue = _Message_queue_Get( id, &queue_context );
33
34  if ( the_message_queue == NULL ) {
35    _Objects_Allocator_unlock();
36
37#if defined(RTEMS_MULTIPROCESSING)
38    if ( _Message_queue_MP_Is_remote( id ) ) {
39      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
40    }
41#endif
42
43    return RTEMS_INVALID_ID;
44  }
45
46  _CORE_message_queue_Acquire_critical(
47    &the_message_queue->message_queue,
48    &queue_context
49  );
50
51  _Objects_Close( &_Message_queue_Information, &the_message_queue->Object );
52
53  _Thread_queue_Context_set_MP_callout(
54    &queue_context,
55    _Message_queue_MP_Send_object_was_deleted
56  );
57  _CORE_message_queue_Close(
58    &the_message_queue->message_queue,
59    &queue_context
60  );
61
62#if defined(RTEMS_MULTIPROCESSING)
63  if ( _Attributes_Is_global( the_message_queue->attribute_set ) ) {
64    _Objects_MP_Close(
65      &_Message_queue_Information,
66      the_message_queue->Object.id
67    );
68
69    _Message_queue_MP_Send_process_packet(
70      MESSAGE_QUEUE_MP_ANNOUNCE_DELETE,
71      the_message_queue->Object.id,
72      0,                         /* Not used */
73      0
74    );
75  }
76#endif
77
78  _Message_queue_Free( the_message_queue );
79  _Objects_Allocator_unlock();
80  return RTEMS_SUCCESSFUL;
81}
Note: See TracBrowser for help on using the repository browser.