1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Rate Monotonic Timeout |
---|
5 | * @ingroup ClassicRateMon |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2009. |
---|
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.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <rtems/system.h> |
---|
22 | #include <rtems/rtems/status.h> |
---|
23 | #include <rtems/rtems/support.h> |
---|
24 | #include <rtems/score/isr.h> |
---|
25 | #include <rtems/score/object.h> |
---|
26 | #include <rtems/rtems/ratemon.h> |
---|
27 | #include <rtems/score/thread.h> |
---|
28 | |
---|
29 | void _Rate_monotonic_Timeout( |
---|
30 | Objects_Id id, |
---|
31 | void *ignored |
---|
32 | ) |
---|
33 | { |
---|
34 | Rate_monotonic_Control *the_period; |
---|
35 | Objects_Locations location; |
---|
36 | Thread_Control *the_thread; |
---|
37 | |
---|
38 | /* |
---|
39 | * When we get here, the Timer is already off the chain so we do not |
---|
40 | * have to worry about that -- hence no _Watchdog_Remove(). |
---|
41 | */ |
---|
42 | the_period = _Rate_monotonic_Get( id, &location ); |
---|
43 | switch ( location ) { |
---|
44 | |
---|
45 | case OBJECTS_LOCAL: |
---|
46 | the_thread = the_period->owner; |
---|
47 | if ( _States_Is_waiting_for_period( the_thread->current_state ) && |
---|
48 | the_thread->Wait.id == the_period->Object.id ) { |
---|
49 | _Thread_Unblock( the_thread ); |
---|
50 | |
---|
51 | _Rate_monotonic_Initiate_statistics( the_period ); |
---|
52 | |
---|
53 | _Watchdog_Insert_ticks( &the_period->Timer, the_period->next_length ); |
---|
54 | } else if ( the_period->state == RATE_MONOTONIC_OWNER_IS_BLOCKING ) { |
---|
55 | the_period->state = RATE_MONOTONIC_EXPIRED_WHILE_BLOCKING; |
---|
56 | |
---|
57 | _Rate_monotonic_Initiate_statistics( the_period ); |
---|
58 | |
---|
59 | _Watchdog_Insert_ticks( &the_period->Timer, the_period->next_length ); |
---|
60 | } else |
---|
61 | the_period->state = RATE_MONOTONIC_EXPIRED; |
---|
62 | _Objects_Put_without_thread_dispatch( &the_period->Object ); |
---|
63 | break; |
---|
64 | |
---|
65 | #if defined(RTEMS_MULTIPROCESSING) |
---|
66 | case OBJECTS_REMOTE: /* impossible */ |
---|
67 | #endif |
---|
68 | case OBJECTS_ERROR: |
---|
69 | break; |
---|
70 | } |
---|
71 | } |
---|