1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Rate Monotonic Get Status |
---|
5 | * @ingroup ClassicRateMon |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * Copyright (c) 2016 embedded brains GmbH. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/rtems/ratemonimpl.h> |
---|
23 | |
---|
24 | rtems_status_code rtems_rate_monotonic_get_status( |
---|
25 | rtems_id id, |
---|
26 | rtems_rate_monotonic_period_status *period_status |
---|
27 | ) |
---|
28 | { |
---|
29 | Rate_monotonic_Control *the_period; |
---|
30 | ISR_lock_Context lock_context; |
---|
31 | rtems_status_code status; |
---|
32 | |
---|
33 | if ( period_status == NULL ) { |
---|
34 | return RTEMS_INVALID_ADDRESS; |
---|
35 | } |
---|
36 | |
---|
37 | the_period = _Rate_monotonic_Get( id, &lock_context ); |
---|
38 | if ( the_period == NULL ) { |
---|
39 | return RTEMS_INVALID_ID; |
---|
40 | } |
---|
41 | |
---|
42 | _Rate_monotonic_Acquire_critical( the_period, &lock_context ); |
---|
43 | |
---|
44 | period_status->owner = the_period->owner->Object.id; |
---|
45 | period_status->state = the_period->state; |
---|
46 | |
---|
47 | if ( the_period->state == RATE_MONOTONIC_INACTIVE ) { |
---|
48 | /* |
---|
49 | * If the period is inactive, there is no information. |
---|
50 | */ |
---|
51 | _Timespec_Set_to_zero( &period_status->since_last_period ); |
---|
52 | _Timespec_Set_to_zero( &period_status->executed_since_last_period ); |
---|
53 | status = RTEMS_SUCCESSFUL; |
---|
54 | } else { |
---|
55 | Timestamp_Control wall_since_last_period; |
---|
56 | Timestamp_Control cpu_since_last_period; |
---|
57 | bool valid_status; |
---|
58 | |
---|
59 | /* |
---|
60 | * Grab the current status. |
---|
61 | */ |
---|
62 | valid_status = _Rate_monotonic_Get_status( |
---|
63 | the_period, |
---|
64 | &wall_since_last_period, |
---|
65 | &cpu_since_last_period |
---|
66 | ); |
---|
67 | if ( valid_status ) { |
---|
68 | _Timestamp_To_timespec( |
---|
69 | &wall_since_last_period, |
---|
70 | &period_status->since_last_period |
---|
71 | ); |
---|
72 | _Timestamp_To_timespec( |
---|
73 | &cpu_since_last_period, |
---|
74 | &period_status->executed_since_last_period |
---|
75 | ); |
---|
76 | status = RTEMS_SUCCESSFUL; |
---|
77 | } else { |
---|
78 | status = RTEMS_NOT_DEFINED; |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | _Rate_monotonic_Release( the_period, &lock_context ); |
---|
83 | return status; |
---|
84 | } |
---|