source: rtems/cpukit/rtems/src/ratemontimeout.c @ 1240aade

5
Last change on this file since 1240aade was 1240aade, checked in by Sebastian Huber <sebastian.huber@…>, on 01/24/17 at 13:37:42

rtems: Fix _Rate_monotonic_Renew_deadline()

Make _Rate_monotonic_Renew_deadline() static and use proper locking in SMP
configurations.

Update #2795.

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[52adc808]1/**
2 *  @file
[5f9b3db]3 *
[52adc808]4 *  @brief Rate Monotonic Timeout
5 *  @ingroup ClassicRateMon
6 */
7
8/*
[94d9bee]9 *  COPYRIGHT (c) 1989-2009.
[5f9b3db]10 *  On-Line Applications Research Corporation (OAR).
11 *
[3a46b72]12 *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
13 *
[5f9b3db]14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
[c499856]16 *  http://www.rtems.org/license/LICENSE.
[5f9b3db]17 */
18
[1095ec1]19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
[ecdcf01]23#include <rtems/rtems/ratemonimpl.h>
[5f9b3db]24
[1240aade]25static void _Rate_monotonic_Renew_deadline(
26  Rate_monotonic_Control *the_period,
27  Thread_Control         *owner,
28  ISR_lock_Context       *lock_context
29)
30{
31  uint64_t deadline;
32
33  ++the_period->postponed_jobs;
34  the_period->state = RATE_MONOTONIC_EXPIRED;
35
36  deadline = _Watchdog_Per_CPU_insert_relative(
37    &the_period->Timer,
38    _Per_CPU_Get(),
39    the_period->next_length
40  );
41  the_period->latest_deadline = deadline;
42
43  _Rate_monotonic_Release( the_period, lock_context );
44}
45
[90960bd]46void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
[5f9b3db]47{
48  Rate_monotonic_Control *the_period;
[90960bd]49  Thread_Control         *owner;
50  ISR_lock_Context        lock_context;
51  Thread_Wait_flags       wait_flags;
52
53  the_period = RTEMS_CONTAINER_OF( the_watchdog, Rate_monotonic_Control, Timer );
54  owner = the_period->owner;
55
56  _ISR_lock_ISR_disable( &lock_context );
[ee0e4135]57  _Rate_monotonic_Acquire_critical( the_period, &lock_context );
[90960bd]58  wait_flags = _Thread_Wait_flags_get( owner );
59
60  if (
61    ( wait_flags & THREAD_WAIT_CLASS_PERIOD ) != 0
62      && owner->Wait.return_argument == the_period
63  ) {
64    bool unblock;
65    bool success;
66
67    owner->Wait.return_argument = NULL;
68
[02987728]69    success = _Thread_Wait_flags_try_change_release(
[90960bd]70      owner,
71      RATE_MONOTONIC_INTEND_TO_BLOCK,
72      RATE_MONOTONIC_READY_AGAIN
73    );
74    if ( success ) {
75      unblock = false;
76    } else {
77      _Assert( _Thread_Wait_flags_get( owner ) == RATE_MONOTONIC_BLOCKED );
78      _Thread_Wait_flags_set( owner, RATE_MONOTONIC_READY_AGAIN );
79      unblock = true;
80    }
81
82    _Rate_monotonic_Restart( the_period, owner, &lock_context );
83
84    if ( unblock ) {
85      _Thread_Unblock( owner );
86    }
[03b900d]87  } else {
[3a46b72]88    _Rate_monotonic_Renew_deadline( the_period, owner, &lock_context );
[5f9b3db]89  }
90}
Note: See TracBrowser for help on using the repository browser.