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