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 | |
---|
44 | rtems_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 | _Objects_Open( |
---|
70 | &_Rate_monotonic_Information, |
---|
71 | &the_period->Object, |
---|
72 | (Objects_Name) name |
---|
73 | ); |
---|
74 | |
---|
75 | *id = the_period->Object.id; |
---|
76 | _Thread_Enable_dispatch(); |
---|
77 | return RTEMS_SUCCESSFUL; |
---|
78 | } |
---|