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

4.104.114.84.95
Last change on this file since f26145b was f3b7be3, checked in by Joel Sherrill <joel.sherrill@…>, on 01/20/05 at 18:22:28

2005-01-20 Joel Sherrill <joel@…>

PR 745/rtems

  • rtems/src/ratemoncreate.c, rtems/src/timercreate.c: Make sure internal timer structures are initialized so object control reuse is safe.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  Rate Monotonic Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/ratemon.h>
25#include <rtems/score/thread.h>
26
27/*PAGE
28 *
29 *  rtems_rate_monotonic_create
30 *
31 *  This directive creates a rate monotonic timer and performs
32 *  some initialization.
33 *
34 *  Input parameters:
35 *    name - name of period
36 *    id   - pointer to rate monotonic id
37 *
38 *  Output parameters:
39 *    id               - rate monotonic id
40 *    RTEMS_SUCCESSFUL - if successful
41 *    error code       - if unsuccessful
42 */
43
44rtems_status_code rtems_rate_monotonic_create(
45  rtems_name    name,
46  Objects_Id   *id
47)
48{
49  Rate_monotonic_Control *the_period;
50
51  if ( !rtems_is_name_valid( name ) )
52    return RTEMS_INVALID_NAME;
53
54  if ( !id )
55    return RTEMS_INVALID_ADDRESS;
56
57  _Thread_Disable_dispatch();            /* to prevent deletion */
58
59  the_period = _Rate_monotonic_Allocate();
60
61  if ( !the_period ) {
62    _Thread_Enable_dispatch();
63    return RTEMS_TOO_MANY;
64  }
65
66  the_period->owner = _Thread_Executing;
67  the_period->state = RATE_MONOTONIC_INACTIVE;
68
69  _Watchdog_Initialize( &the_period->Timer, NULL, 0, NULL );
70
71  _Objects_Open(
72    &_Rate_monotonic_Information,
73    &the_period->Object,
74    (Objects_Name) name
75  );
76
77  *id = the_period->Object.id;
78  _Thread_Enable_dispatch();
79  return RTEMS_SUCCESSFUL;
80}
Note: See TracBrowser for help on using the repository browser.