source: rtems/cpukit/rtems/include/rtems/rtems/ratemonimpl.h @ 1240aade

5
Last change on this file since 1240aade was 1240aade, checked in by Sebastian Huber <sebastian.huber@…>, on 01/24/17 at 13:37:42

rtems: Fix _Rate_monotonic_Renew_deadline()

Make _Rate_monotonic_Renew_deadline() static and use proper locking in SMP
configurations.

Update #2795.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ClassicRateMonImpl
5 *
6 * @brief Classic Rate Monotonic Scheduler Implementation
7 */
8
9/*  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *  Copyright (c) 2016 embedded brains GmbH.
12 *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_RTEMS_RATEMONIMPL_H
20#define _RTEMS_RTEMS_RATEMONIMPL_H
21
22#include <rtems/rtems/ratemon.h>
23#include <rtems/score/objectimpl.h>
24#include <rtems/score/schedulerimpl.h>
25#include <rtems/score/threadimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28#include <string.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * @defgroup ClassicRateMonImpl Classic Rate Monotonic Scheduler Implementation
36 *
37 * @ingroup ClassicRateMon
38 *
39 * @{
40 */
41
42#define RATE_MONOTONIC_INTEND_TO_BLOCK \
43  ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_INTEND_TO_BLOCK )
44
45#define RATE_MONOTONIC_BLOCKED \
46  ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_BLOCKED )
47
48#define RATE_MONOTONIC_READY_AGAIN \
49  ( THREAD_WAIT_CLASS_PERIOD | THREAD_WAIT_STATE_READY_AGAIN )
50
51/**
52 *  @brief Rate Monotonic Period Class Management Structure
53 *
54 *  This instance of Objects_Information is used to manage the
55 *  set of rate monotonic period instances.
56 */
57extern Objects_Information _Rate_monotonic_Information;
58
59/**
60 *  @brief Allocates a period control block from
61 *  the inactive chain of free period control blocks.
62 *
63 *  This function allocates a period control block from
64 *  the inactive chain of free period control blocks.
65 */
66RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
67{
68  return (Rate_monotonic_Control *)
69    _Objects_Allocate( &_Rate_monotonic_Information );
70}
71
72RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
73  Rate_monotonic_Control *the_period,
74  ISR_lock_Context       *lock_context
75)
76{
77  _ISR_lock_Acquire( &the_period->Lock, lock_context );
78}
79
80RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
81  Rate_monotonic_Control *the_period,
82  ISR_lock_Context       *lock_context
83)
84{
85  _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context );
86}
87
88RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
89  Objects_Id        id,
90  ISR_lock_Context *lock_context
91)
92{
93  return (Rate_monotonic_Control *)
94    _Objects_Get( id, lock_context, &_Rate_monotonic_Information );
95}
96
97void _Rate_monotonic_Timeout( Watchdog_Control *watchdog );
98
99/**
100 * @brief _Rate_monotonic_Get_status(
101 *
102 * This routine is invoked to compute the elapsed wall time and cpu
103 * time for a period.
104 *
105 * @param[in] the_period points to the period being operated upon.
106 * @param[out] wall_since_last_period is set to the wall time elapsed
107 *             since the period was initiated.
108 * @param[out] cpu_since_last_period is set to the cpu time used by the
109 *             owning thread since the period was initiated.
110 *
111 * @retval This routine returns true if the status can be determined
112 *         and false otherwise.
113 */
114bool _Rate_monotonic_Get_status(
115  const Rate_monotonic_Control *the_period,
116  Timestamp_Control            *wall_since_last_period,
117  Timestamp_Control            *cpu_since_last_period
118);
119
120void _Rate_monotonic_Restart(
121  Rate_monotonic_Control *the_period,
122  Thread_Control         *owner,
123  ISR_lock_Context       *lock_context
124);
125
126void _Rate_monotonic_Cancel(
127  Rate_monotonic_Control *the_period,
128  Thread_Control         *owner,
129  ISR_lock_Context       *lock_context
130);
131
132RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time(
133  Timestamp_Control *min_time
134)
135{
136  _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff );
137}
138
139RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics(
140  Rate_monotonic_Control *the_period
141)
142{
143  Rate_monotonic_Statistics *statistics;
144
145  statistics = &the_period->Statistics;
146  memset( statistics, 0, sizeof( *statistics ) );
147  _Rate_monotonic_Reset_min_time( &statistics->min_wall_time );
148  _Rate_monotonic_Reset_min_time( &statistics->min_cpu_time );
149}
150
151/**@}*/
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif
158/* end of include file */
Note: See TracBrowser for help on using the repository browser.