source: rtems/cpukit/rtems/src/ratemontimeout.c @ 3a46b72

5
Last change on this file since 3a46b72 was 3a46b72, checked in by Kuan-Hsun Chen <c0066c@…>, on 12/21/16 at 16:42:39

Enhancement of the RMS manager for the overrun handling.

Three additional functions:
rtems_rate_monotonic_postponed_job_count,
_Rate_monotonic_Renew_deadline, and _Rate_monotonic_Release_postponed_job.

Four refined functions:
_Rate_monotonic_Activate, _Rate_monotonic_Block_while_expired,
rtems_rate_monotonic_period, _Rate_monotonic_Timeout.

Rate_monotonic_Control contains one counter for counting the postponed jobs
and one for recording the recent deadline.

Update #2795.

  • Property mode set to 100644
File size: 2.0 KB
Line 
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 *  COPYRIGHT (c) 2016 Kuan-Hsun Chen.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#if HAVE_CONFIG_H
20#include "config.h"
21#endif
22
23#include <rtems/rtems/ratemonimpl.h>
24
25void _Rate_monotonic_Timeout( Watchdog_Control *the_watchdog )
26{
27  Rate_monotonic_Control *the_period;
28  Thread_Control         *owner;
29  ISR_lock_Context        lock_context;
30  Thread_Wait_flags       wait_flags;
31
32  the_period = RTEMS_CONTAINER_OF( the_watchdog, Rate_monotonic_Control, Timer );
33  owner = the_period->owner;
34
35  _ISR_lock_ISR_disable( &lock_context );
36  _Rate_monotonic_Acquire_critical( the_period, &lock_context );
37  wait_flags = _Thread_Wait_flags_get( owner );
38
39  if (
40    ( wait_flags & THREAD_WAIT_CLASS_PERIOD ) != 0
41      && owner->Wait.return_argument == the_period
42  ) {
43    bool unblock;
44    bool success;
45
46    owner->Wait.return_argument = NULL;
47
48    success = _Thread_Wait_flags_try_change_release(
49      owner,
50      RATE_MONOTONIC_INTEND_TO_BLOCK,
51      RATE_MONOTONIC_READY_AGAIN
52    );
53    if ( success ) {
54      unblock = false;
55    } else {
56      _Assert( _Thread_Wait_flags_get( owner ) == RATE_MONOTONIC_BLOCKED );
57      _Thread_Wait_flags_set( owner, RATE_MONOTONIC_READY_AGAIN );
58      unblock = true;
59    }
60
61    _Rate_monotonic_Restart( the_period, owner, &lock_context );
62
63    if ( unblock ) {
64      _Thread_Unblock( owner );
65    }
66  } else {
67    /*
68     * If the watchdog is timeout, it means there is an additional postponed
69     * job in the next period but it is not available to release now:
70     * Either the current task is still executed, or it is preemptive by the
71     * other higher priority tasks.
72     */
73    the_period->postponed_jobs += 1;
74    the_period->state = RATE_MONOTONIC_EXPIRED;
75    _Rate_monotonic_Renew_deadline( the_period, owner, &lock_context );
76  }
77}
Note: See TracBrowser for help on using the repository browser.