source: rtems/cpukit/rtems/src/ratemoncreate.c @ a2e3f33

4.115
Last change on this file since a2e3f33 was a2e3f33, checked in by Sebastian Huber <sebastian.huber@…>, on 07/24/13 at 11:50:54

score: Create object implementation header

Move implementation specific parts of object.h and object.inl into new
header file objectimpl.h. The object.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Create a Period
5 * @ingroup ClassicRateMon Rate Monotonic Scheduler
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/isr.h>
25#include <rtems/rtems/ratemonimpl.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/watchdogimpl.h>
28
29/*
30 *  rtems_rate_monotonic_create
31 *
32 *  This directive creates a rate monotonic timer and performs
33 *  some initialization.
34 *
35 *  Input parameters:
36 *    name - name of period
37 *    id   - pointer to rate monotonic id
38 *
39 *  Output parameters:
40 *    id               - rate monotonic id
41 *    RTEMS_SUCCESSFUL - if successful
42 *    error code       - if unsuccessful
43 */
44
45rtems_status_code rtems_rate_monotonic_create(
46  rtems_name  name,
47  rtems_id   *id
48)
49{
50  Rate_monotonic_Control *the_period;
51
52  if ( !rtems_is_name_valid( name ) )
53    return RTEMS_INVALID_NAME;
54
55  if ( !id )
56    return RTEMS_INVALID_ADDRESS;
57
58  _Thread_Disable_dispatch();            /* to prevent deletion */
59
60  the_period = _Rate_monotonic_Allocate();
61
62  if ( !the_period ) {
63    _Thread_Enable_dispatch();
64    return RTEMS_TOO_MANY;
65  }
66
67  the_period->owner = _Thread_Executing;
68  the_period->state = RATE_MONOTONIC_INACTIVE;
69
70  _Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
71
72  _Rate_monotonic_Reset_statistics( the_period );
73
74  _Objects_Open(
75    &_Rate_monotonic_Information,
76    &the_period->Object,
77    (Objects_Name) name
78  );
79
80  *id = the_period->Object.id;
81  _Thread_Enable_dispatch();
82  return RTEMS_SUCCESSFUL;
83}
Note: See TracBrowser for help on using the repository browser.