1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS Rate Monotonic Cancel |
---|
5 | * @ingroup ClassicRateMon |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * Copyright (c) 2016 embedded brains GmbH. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #if HAVE_CONFIG_H |
---|
19 | #include "config.h" |
---|
20 | #endif |
---|
21 | |
---|
22 | #include <rtems/rtems/ratemonimpl.h> |
---|
23 | |
---|
24 | void _Rate_monotonic_Cancel( |
---|
25 | Rate_monotonic_Control *the_period, |
---|
26 | Thread_Control *owner, |
---|
27 | ISR_lock_Context *lock_context |
---|
28 | ) |
---|
29 | { |
---|
30 | Per_CPU_Control *cpu_self; |
---|
31 | |
---|
32 | _Watchdog_Per_CPU_remove_relative( &the_period->Timer ); |
---|
33 | |
---|
34 | owner = the_period->owner; |
---|
35 | _Rate_monotonic_Acquire_critical( owner, lock_context ); |
---|
36 | the_period->state = RATE_MONOTONIC_INACTIVE; |
---|
37 | |
---|
38 | cpu_self = _Thread_Dispatch_disable_critical( lock_context ); |
---|
39 | _Rate_monotonic_Release( owner, lock_context ); |
---|
40 | |
---|
41 | _Scheduler_Cancel_job( owner ); |
---|
42 | |
---|
43 | _Thread_Dispatch_enable( cpu_self ); |
---|
44 | } |
---|
45 | |
---|
46 | rtems_status_code rtems_rate_monotonic_cancel( |
---|
47 | rtems_id id |
---|
48 | ) |
---|
49 | { |
---|
50 | Rate_monotonic_Control *the_period; |
---|
51 | ISR_lock_Context lock_context; |
---|
52 | Thread_Control *executing; |
---|
53 | |
---|
54 | the_period = _Rate_monotonic_Get( id, &lock_context ); |
---|
55 | if ( the_period == NULL ) { |
---|
56 | return RTEMS_INVALID_ID; |
---|
57 | } |
---|
58 | |
---|
59 | executing = _Thread_Executing; |
---|
60 | if ( executing != the_period->owner ) { |
---|
61 | _ISR_lock_ISR_enable( &lock_context ); |
---|
62 | return RTEMS_NOT_OWNER_OF_RESOURCE; |
---|
63 | } |
---|
64 | |
---|
65 | _Rate_monotonic_Cancel( the_period, executing, &lock_context ); |
---|
66 | return RTEMS_SUCCESSFUL; |
---|
67 | } |
---|