source: rtems/cpukit/include/rtems/rtems/ratemonimpl.h @ 6b0a729b

5
Last change on this file since 6b0a729b was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on 11/22/18 at 18:14:51

score: Static Objects_Information initialization

Statically allocate the objects information together with the initial
set of objects either via <rtems/confdefs.h>. Provide default object
informations with zero objects via librtemscpu.a. This greatly
simplifies the workspace size estimate. RTEMS applications which do not
use the unlimited objects option are easier to debug since all objects
reside now in statically allocated objects of the right types.

Close #3621.

  • Property mode set to 100644
File size: 3.8 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/ratemondata.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 Allocates a period control block from
53 *  the inactive chain of free period control blocks.
54 *
55 *  This function allocates a period control block from
56 *  the inactive chain of free period control blocks.
57 */
58RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Allocate( void )
59{
60  return (Rate_monotonic_Control *)
61    _Objects_Allocate( &_Rate_monotonic_Information );
62}
63
64RTEMS_INLINE_ROUTINE void _Rate_monotonic_Acquire_critical(
65  Rate_monotonic_Control *the_period,
66  ISR_lock_Context       *lock_context
67)
68{
69  _ISR_lock_Acquire( &the_period->Lock, lock_context );
70}
71
72RTEMS_INLINE_ROUTINE void _Rate_monotonic_Release(
73  Rate_monotonic_Control *the_period,
74  ISR_lock_Context       *lock_context
75)
76{
77  _ISR_lock_Release_and_ISR_enable( &the_period->Lock, lock_context );
78}
79
80RTEMS_INLINE_ROUTINE Rate_monotonic_Control *_Rate_monotonic_Get(
81  Objects_Id        id,
82  ISR_lock_Context *lock_context
83)
84{
85  return (Rate_monotonic_Control *)
86    _Objects_Get( id, lock_context, &_Rate_monotonic_Information );
87}
88
89void _Rate_monotonic_Timeout( Watchdog_Control *watchdog );
90
91/**
92 * @brief _Rate_monotonic_Get_status(
93 *
94 * This routine is invoked to compute the elapsed wall time and cpu
95 * time for a period.
96 *
97 * @param[in] the_period points to the period being operated upon.
98 * @param[out] wall_since_last_period is set to the wall time elapsed
99 *             since the period was initiated.
100 * @param[out] cpu_since_last_period is set to the cpu time used by the
101 *             owning thread since the period was initiated.
102 *
103 * @retval This routine returns true if the status can be determined
104 *         and false otherwise.
105 */
106bool _Rate_monotonic_Get_status(
107  const Rate_monotonic_Control *the_period,
108  Timestamp_Control            *wall_since_last_period,
109  Timestamp_Control            *cpu_since_last_period
110);
111
112void _Rate_monotonic_Restart(
113  Rate_monotonic_Control *the_period,
114  Thread_Control         *owner,
115  ISR_lock_Context       *lock_context
116);
117
118void _Rate_monotonic_Cancel(
119  Rate_monotonic_Control *the_period,
120  Thread_Control         *owner,
121  ISR_lock_Context       *lock_context
122);
123
124RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_min_time(
125  Timestamp_Control *min_time
126)
127{
128  _Timestamp_Set( min_time, 0x7fffffff, 0x7fffffff );
129}
130
131RTEMS_INLINE_ROUTINE void _Rate_monotonic_Reset_statistics(
132  Rate_monotonic_Control *the_period
133)
134{
135  Rate_monotonic_Statistics *statistics;
136
137  statistics = &the_period->Statistics;
138  memset( statistics, 0, sizeof( *statistics ) );
139  _Rate_monotonic_Reset_min_time( &statistics->min_wall_time );
140  _Rate_monotonic_Reset_min_time( &statistics->min_cpu_time );
141}
142
143/**@}*/
144
145#ifdef __cplusplus
146}
147#endif
148
149#endif
150/* end of include file */
Note: See TracBrowser for help on using the repository browser.