source: rtems/cpukit/include/rtems/rtems/ratemonimpl.h @ a2ed06e

Last change on this file since a2ed06e was a2ed06e, checked in by Joel Sherrill <joel@…>, on 02/16/22 at 22:29:38

cpukit/include/rtems/rtems/*.h: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicRateMonotonic
7 *
8 * @brief This header file provides the implementation interfaces of
9 *   the @ref RTEMSImplClassicRateMonotonic.
10 */
11
12/*  COPYRIGHT (c) 1989-2008.
13 *  On-Line Applications Research Corporation (OAR).
14 *  Copyright (c) 2016 embedded brains GmbH.
15 *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_RTEMS_RATEMONIMPL_H
40#define _RTEMS_RTEMS_RATEMONIMPL_H
41
42#include <rtems/rtems/ratemondata.h>
43#include <rtems/score/objectimpl.h>
44#include <rtems/score/schedulerimpl.h>
45#include <rtems/score/threadimpl.h>
46#include <rtems/score/watchdogimpl.h>
47
48#include <string.h>
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54/**
55 * @defgroup RTEMSImplClassicRateMonotonic Rate Monotonic Manager
56 *
57 * @ingroup RTEMSImplClassic
58 *
59 * @brief This group contains the Rate Monotonic Manager implementation.
60 *
61 * @{
62 */
63
64#define RATE_MONOTONIC_INTEND_TO_BLOCK \
65  ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_INTEND_TO_BLOCK )
66
67#define RATE_MONOTONIC_BLOCKED \
68  ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED )
69
70/**
71 *  @brief Allocates a period control block from
72 *  the inactive chain of free period control blocks.
73 *
74 *  This function allocates a period control block from
75 *  the inactive chain of free period control blocks.
76 */
77RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
78{
79  return (Rate_monotonic_Control *)
80    _Objects_Allocate( &_Rate_monotonic_Information );
81}
82
83RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
84  Rate_monotonic_Control *the_period,
85  ISR_lock_Context       *lock_context
86)
87{
88  _ISR_lock_Acquire( &the_period->Lock, lock_context );
89}
90
91RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
92  Rate_monotonic_Control *the_period,
93  ISR_lock_Context       *lock_context
94)
95{
96  _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context );
97}
98
99RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
100  Objects_Id        id,
101  ISR_lock_Context *lock_context
102)
103{
104  return (Rate_monotonic_Control *)
105    _Objects_Get( id, lock_context, &_Rate_monotonic_Information );
106}
107
108void _Rate_monotonic_Timeout( Watchdog_Control *watchdog );
109
110/**
111 * @brief Gets the rate monotonic CPU usage status.
112 *
113 * This routine is invoked to compute the elapsed wall time and cpu
114 * time for a period.
115 *
116 * @param[in] the_period points to the period being operated upon.
117 * @param[out] wall_since_last_period is set to the wall time elapsed
118 *             since the period was initiated.
119 * @param[out] cpu_since_last_period is set to the cpu time used by the
120 *             owning thread since the period was initiated.
121 */
122void _Rate_monotonic_Get_status(
123  const Rate_monotonic_Control *the_period,
124  Timestamp_Control            *wall_since_last_period,
125  Timestamp_Control            *cpu_since_last_period
126);
127
128void _Rate_monotonic_Restart(
129  Rate_monotonic_Control *the_period,
130  Thread_Control         *owner,
131  ISR_lock_Context       *lock_context
132);
133
134void _Rate_monotonic_Cancel(
135  Rate_monotonic_Control *the_period,
136  Thread_Control         *owner,
137  ISR_lock_Context       *lock_context
138);
139
140RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time(
141  Timestamp_Control *min_time
142)
143{
144  _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff );
145}
146
147RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics(
148  Rate_monotonic_Control *the_period
149)
150{
151  Rate_monotonic_Statistics *statistics;
152
153  statistics = &the_period->Statistics;
154  memset( statistics, 0, sizeof( *statistics ) );
155  _Rate_monotonic_Reset_min_time( &statistics->min_wall_time );
156  _Rate_monotonic_Reset_min_time( &statistics->min_cpu_time );
157}
158
159/**@}*/
160
161#ifdef __cplusplus
162}
163#endif
164
165#endif
166/* end of include file */
Note: See TracBrowser for help on using the repository browser.