summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/ratemondelete.c
blob: 385d08fda9ae3222719ee4d972f7242d1e7659b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
 *  @file
 *
 *  @brief RTEMS Delete Rate Monotonic
 *  @ingroup ClassicRateMon
 */

/*
 *  COPYRIGHT (c) 1989-2007.
 *  On-Line Applications Research Corporation (OAR).
 *  Copyright (c) 2016 embedded brains GmbH.
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <rtems/rtems/ratemonimpl.h>

rtems_status_code rtems_rate_monotonic_delete(
  rtems_id id
)
{
  Rate_monotonic_Control *the_period;
  ISR_lock_Context        lock_context;
  rtems_status_code       status;

  _Objects_Allocator_lock();

  the_period = _Rate_monotonic_Get( id, &lock_context );
  if ( the_period != NULL ) {
    _Objects_Close( &_Rate_monotonic_Information, &the_period->Object );
    _Rate_monotonic_Cancel( the_period, the_period->owner, &lock_context );
    _Objects_Free( &_Rate_monotonic_Information, &the_period->Object );
    status = RTEMS_SUCCESSFUL;
  } else {
    status = RTEMS_INVALID_ID;
  }

  _Objects_Allocator_unlock();

  return status;
}