source: rtems/cpukit/rtems/src/semflush.c @ 0e1d11f3

5
Last change on this file since 0e1d11f3 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 Semaphore Flush
5 *  @ingroup ClassicSem
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/semimpl.h>
22#include <rtems/rtems/attrimpl.h>
23
24rtems_status_code rtems_semaphore_flush( rtems_id id )
25{
26  Semaphore_Control    *the_semaphore;
27  Thread_queue_Context  queue_context;
28  rtems_attribute       attribute_set;
29
30  the_semaphore = _Semaphore_Get( id, &queue_context );
31
32  if ( the_semaphore == NULL ) {
33#if defined(RTEMS_MULTIPROCESSING)
34    if ( _Semaphore_MP_Is_remote( id ) ) {
35      return RTEMS_ILLEGAL_ON_REMOTE_OBJECT;
36    }
37#endif
38
39    return RTEMS_INVALID_ID;
40  }
41
42  attribute_set = the_semaphore->attribute_set;
43
44  _Thread_queue_Context_set_MP_callout(
45    &queue_context,
46    _Semaphore_MP_Send_object_was_deleted
47  );
48
49#if defined(RTEMS_SMP)
50  if ( _Attributes_Is_multiprocessor_resource_sharing( attribute_set ) ) {
51    _ISR_lock_ISR_enable( &queue_context.Lock_context );
52    return RTEMS_NOT_DEFINED;
53  } else
54#endif
55  if ( !_Attributes_Is_counting_semaphore( attribute_set ) ) {
56    _CORE_mutex_Acquire_critical(
57      &the_semaphore->Core_control.mutex,
58      &queue_context
59    );
60    _CORE_mutex_Flush(
61      &the_semaphore->Core_control.mutex,
62      _Thread_queue_Flush_status_unavailable,
63      &queue_context
64    );
65  } else {
66    _CORE_semaphore_Acquire_critical(
67      &the_semaphore->Core_control.semaphore,
68      &queue_context
69    );
70    _CORE_semaphore_Flush(
71      &the_semaphore->Core_control.semaphore,
72      &queue_context
73    );
74  }
75  return RTEMS_SUCCESSFUL;
76}
Note: See TracBrowser for help on using the repository browser.