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

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.0 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_get_status
30 *
31 *  This directive allows a thread to obtain status information on a
32 *  period.
33 *
34 *  Input parameters:
35 *    id     - rate monotonic id
36 *    status - pointer to status control block
37 *
38 *  Output parameters:
39 *    RTEMS_SUCCESSFUL - if successful
40 *    error code        - if unsuccessful
41 *
42 */
43
44rtems_status_code rtems_rate_monotonic_get_status(
45  Objects_Id                           id,
46  rtems_rate_monotonic_period_status  *status
47)
48{
49  Objects_Locations              location;
50  Rate_monotonic_Control        *the_period;
51
52  if ( !status )
53    return RTEMS_INVALID_ADDRESS;
54
55  the_period = _Rate_monotonic_Get( id, &location );
56  switch ( location ) {
57    case OBJECTS_REMOTE:            /* should never return this */
58      return RTEMS_INTERNAL_ERROR;
59
60    case OBJECTS_ERROR:
61      return RTEMS_INVALID_ID;
62
63    case OBJECTS_LOCAL:
64      status->state = the_period->state;
65
66      if ( status->state == RATE_MONOTONIC_INACTIVE ) {
67        status->ticks_since_last_period = 0;
68        status->ticks_executed_since_last_period = 0;
69      } else {
70        status->ticks_since_last_period =
71          _Watchdog_Ticks_since_boot - the_period->time_at_period;
72
73        status->ticks_executed_since_last_period =
74          the_period->owner->ticks_executed -
75            the_period->owner_ticks_executed_at_period;
76      }
77
78      _Thread_Enable_dispatch();
79      return RTEMS_SUCCESSFUL;
80  }
81
82  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
83}
Note: See TracBrowser for help on using the repository browser.