source: rtems/cpukit/rtems/src/ratemoncreate.c @ 21275b58

Last change on this file since 21275b58 was 21275b58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 22, 2018 at 6:14:51 PM

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: 1.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Create a Period
5 * @ingroup ClassicRateMon Rate Monotonic Scheduler
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/ratemonimpl.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/isr.h>
25#include <rtems/score/thread.h>
26#include <rtems/score/watchdogimpl.h>
27#include <rtems/sysinit.h>
28
29rtems_status_code rtems_rate_monotonic_create(
30  rtems_name  name,
31  rtems_id   *id
32)
33{
34  Rate_monotonic_Control *the_period;
35
36  if ( !rtems_is_name_valid( name ) )
37    return RTEMS_INVALID_NAME;
38
39  if ( !id )
40    return RTEMS_INVALID_ADDRESS;
41
42  the_period = _Rate_monotonic_Allocate();
43
44  if ( !the_period ) {
45    _Objects_Allocator_unlock();
46    return RTEMS_TOO_MANY;
47  }
48
49  _ISR_lock_Initialize( &the_period->Lock, "Rate Monotonic Period" );
50  _Priority_Node_initialize( &the_period->Priority, 0 );
51  _Priority_Node_set_inactive( &the_period->Priority );
52
53  the_period->owner = _Thread_Get_executing();
54  the_period->state = RATE_MONOTONIC_INACTIVE;
55
56  _Watchdog_Preinitialize( &the_period->Timer, _Per_CPU_Get_by_index( 0 ) );
57  _Watchdog_Initialize( &the_period->Timer, _Rate_monotonic_Timeout );
58
59  _Rate_monotonic_Reset_statistics( the_period );
60
61  _Objects_Open(
62    &_Rate_monotonic_Information,
63    &the_period->Object,
64    (Objects_Name) name
65  );
66
67  *id = the_period->Object.id;
68  _Objects_Allocator_unlock();
69  return RTEMS_SUCCESSFUL;
70}
71
72static void _Rate_monotonic_Manager_initialization( void )
73{
74  _Objects_Initialize_information( &_Rate_monotonic_Information );
75}
76
77RTEMS_SYSINIT_ITEM(
78  _Rate_monotonic_Manager_initialization,
79  RTEMS_SYSINIT_CLASSIC_RATE_MONOTONIC,
80  RTEMS_SYSINIT_ORDER_MIDDLE
81);
Note: See TracBrowser for help on using the repository browser.