source: rtems/cpukit/rtems/src/ratemongetstatus.c @ df40cc9

4.115
Last change on this file since df40cc9 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.7 KB
Line 
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 *
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.org/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
28#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
29  #include <rtems/score/timespec.h>
30#endif
31
32rtems_status_code rtems_rate_monotonic_get_status(
33  rtems_id                            id,
34  rtems_rate_monotonic_period_status *status
35)
36{
37  Thread_CPU_usage_t             executed;
38  Objects_Locations              location;
39  Rate_monotonic_Period_time_t   since_last_period;
40  Rate_monotonic_Control        *the_period;
41  bool                           valid_status;
42
43  if ( !status )
44    return RTEMS_INVALID_ADDRESS;
45
46  the_period = _Rate_monotonic_Get( id, &location );
47  switch ( location ) {
48
49    case OBJECTS_LOCAL:
50      status->owner = the_period->owner->Object.id;
51      status->state = the_period->state;
52
53      /*
54       *  If the period is inactive, there is no information.
55       */
56      if ( status->state == RATE_MONOTONIC_INACTIVE ) {
57        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
58          _Timespec_Set_to_zero( &status->since_last_period );
59          _Timespec_Set_to_zero( &status->executed_since_last_period );
60        #else
61          status->since_last_period = 0;
62          status->executed_since_last_period = 0;
63        #endif
64
65      } else {
66
67        /*
68         *  Grab the current status.
69         */
70        valid_status =
71          _Rate_monotonic_Get_status(
72            the_period, &since_last_period, &executed
73          );
74        if (!valid_status) {
75          _Objects_Put( &the_period->Object );
76          return RTEMS_NOT_DEFINED;
77        }
78
79        #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
80          _Timestamp_To_timespec(
81            &since_last_period, &status->since_last_period
82          );
83          _Timestamp_To_timespec(
84            &executed, &status->executed_since_last_period
85          );
86        #else
87          status->since_last_period = since_last_period;
88          status->executed_since_last_period = executed;
89        #endif
90      }
91
92      _Objects_Put( &the_period->Object );
93      return RTEMS_SUCCESSFUL;
94
95#if defined(RTEMS_MULTIPROCESSING)
96    case OBJECTS_REMOTE:            /* should never return this */
97#endif
98    case OBJECTS_ERROR:
99      break;
100  }
101
102  return RTEMS_INVALID_ID;
103}
Note: See TracBrowser for help on using the repository browser.