source: rtems/cpukit/rtems/src/ratemontimeout.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  Rate Monotonic Manager
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/object.h>
24#include <rtems/rtems/ratemon.h>
25#include <rtems/score/thread.h>
26
27/*PAGE
28 *
29 *  _Rate_monotonic_Timeout
30 *
31 *  This routine processes a period ending.  If the owning thread
32 *  is waiting for the period, that thread is unblocked and the
33 *  period reinitiated.  Otherwise, the period is expired.
34 *  This routine is called by the watchdog handler.
35 *
36 *  Input parameters:
37 *    id - period id
38 *
39 *  Output parameters: NONE
40 */
41
42void _Rate_monotonic_Timeout(
43  Objects_Id  id,
44  void       *ignored
45)
46{
47  Rate_monotonic_Control *the_period;
48  Objects_Locations       location;
49  Thread_Control         *the_thread;
50
51  /*
52   *  When we get here, the Timer is already off the chain so we do not
53   *  have to worry about that -- hence no _Watchdog_Remove().
54   */
55
56  the_period = _Rate_monotonic_Get( id, &location );
57  switch ( location ) {
58    case OBJECTS_REMOTE:  /* impossible */
59    case OBJECTS_ERROR:
60      break;
61
62    case OBJECTS_LOCAL:
63      the_thread = the_period->owner;
64      if ( _States_Is_waiting_for_period( the_thread->current_state ) &&
65            the_thread->Wait.id == the_period->Object.id ) {
66        _Thread_Unblock( the_thread );
67        the_period->owner_ticks_executed_at_period =
68          the_thread->ticks_executed;
69
70        the_period->time_at_period = _Watchdog_Ticks_since_boot;
71
72        _Watchdog_Insert_ticks( &the_period->Timer, the_period->next_length );
73      } else if ( the_period->state == RATE_MONOTONIC_OWNER_IS_BLOCKING ) {
74        the_period->state = RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING;
75        the_period->owner_ticks_executed_at_period =
76          the_thread->ticks_executed;
77
78        the_period->time_at_period = _Watchdog_Ticks_since_boot;
79        _Watchdog_Insert_ticks( &the_period->Timer, the_period->next_length );
80      } else
81        the_period->state = RATE_MONOTONIC_EXPIRED;
82      _Thread_Unnest_dispatch();
83      break;
84  }
85}
Note: See TracBrowser for help on using the repository browser.