source: rtems/cpukit/rtems/src/ratemongetstatus.c @ 90960bd

5
Last change on this file since 90960bd was 90960bd, checked in by Sebastian Huber <sebastian.huber@…>, on 03/21/16 at 14:01:57

rtems: Rework rate-monotonic scheduler

Use the default thread lock to protect rate-monotonic state changes.
This avoids use of the Giant lock. Split rtems_rate_monotonic_period()
body into several static functions. Introduce a new thread wait class
THREAD_WAIT_CLASS_PERIOD for period objects to synchronize the blocking
operation.

Close #2631.

  • Property mode set to 100644
File size: 2.1 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 *  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
24rtems_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  Thread_Control         *owner;
32  rtems_status_code       status;
33
34  if ( period_status == NULL ) {
35    return RTEMS_INVALID_ADDRESS;
36  }
37
38  the_period = _Rate_monotonic_Get( id, &lock_context );
39  if ( the_period == NULL ) {
40    return RTEMS_INVALID_ID;
41  }
42
43  owner = the_period->owner;
44  _Rate_monotonic_Acquire_critical( owner, &lock_context );
45
46  period_status->owner = owner->Object.id;
47  period_status->state = the_period->state;
48
49  if ( the_period->state == RATE_MONOTONIC_INACTIVE ) {
50    /*
51     *  If the period is inactive, there is no information.
52     */
53    _Timespec_Set_to_zero( &period_status->since_last_period );
54    _Timespec_Set_to_zero( &period_status->executed_since_last_period );
55    status = RTEMS_SUCCESSFUL;
56  } else {
57    Timestamp_Control wall_since_last_period;
58    Timestamp_Control cpu_since_last_period;
59    bool              valid_status;
60
61    /*
62     *  Grab the current status.
63     */
64    valid_status = _Rate_monotonic_Get_status(
65      the_period,
66      &wall_since_last_period,
67      &cpu_since_last_period
68    );
69    if ( valid_status ) {
70      _Timestamp_To_timespec(
71        &wall_since_last_period,
72        &period_status->since_last_period
73      );
74      _Timestamp_To_timespec(
75        &cpu_since_last_period,
76        &period_status->executed_since_last_period
77      );
78      status = RTEMS_SUCCESSFUL;
79    } else {
80      status = RTEMS_NOT_DEFINED;
81    }
82  }
83
84  _Rate_monotonic_Release( owner, &lock_context );
85  return status;
86}
Note: See TracBrowser for help on using the repository browser.