RTEMS
ratemongetstatus.c
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 1989-2009.
10  * On-Line Applications Research Corporation (OAR).
11  * Copyright (c) 2016 embedded brains GmbH.
12  * Copyright (c) 2017 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 #ifdef HAVE_CONFIG_H
20 #include "config.h"
21 #endif
22 
24 
26  rtems_id id,
28 )
29 {
30  Rate_monotonic_Control *the_period;
31  ISR_lock_Context lock_context;
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  _Rate_monotonic_Acquire_critical( the_period, &lock_context );
44 
45  period_status->owner = the_period->owner->Object.id;
46  period_status->state = the_period->state;
47  period_status->postponed_jobs_count = the_period->postponed_jobs;
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 );
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 ) {
71  &wall_since_last_period,
72  &period_status->since_last_period
73  );
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( the_period, &lock_context );
85  return status;
86 }
int64_t Timestamp_Control
Definition: timestamp.h:57
uint32_t postponed_jobs_count
This member is.
Definition: ratemon.h:210
Thread_Control * owner
Definition: ratemondata.h:100
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
#define _Timespec_Set_to_zero(_time)
Sets the Timespec to Zero.
Definition: timespec.h:66
bool _Rate_monotonic_Get_status(const Rate_monotonic_Control *the_period, Timestamp_Control *wall_since_last_period, Timestamp_Control *cpu_since_last_period)
_Rate_monotonic_Get_status(
Definition: ratemonperiod.c:27
Objects_Control Object
Definition: thread.h:727
rtems_rate_monotonic_period_states state
Definition: ratemondata.h:82
This status code indicates that a specified address was invalid.
Definition: status.h:133
The following structure defines the control block used to manage each period.
Definition: ratemondata.h:69
rtems_id owner
This member is.
Definition: ratemon.h:182
This status code indicates that the item has not been initialized.
Definition: status.h:143
This status code indicates that an object identifier was invalid.
Definition: status.h:106
Objects_Id rtems_id
Values of this type identify an RTEMS object.
Definition: types.h:99
static __inline__ void _Timestamp_To_timespec(const Timestamp_Control *_timestamp, struct timespec *_timespec)
Converts timestamp to struct timespec.
Classic Rate Monotonic Scheduler Implementation.
struct timespec since_last_period
This member is.
Definition: ratemon.h:196
rtems_rate_monotonic_period_states state
This member is.
Definition: ratemon.h:189
Local ISR lock context for acquire and release pairs.
Definition: isrlock.h:65
struct timespec executed_since_last_period
This member is.
Definition: ratemon.h:203
rtems_status_code rtems_rate_monotonic_get_status(rtems_id id, rtems_rate_monotonic_period_status *period_status)
%
Objects_Id id
Definition: objectdata.h:43