source: rtems/cpukit/score/src/schedulercbsunblock.c @ 63e2ca1b

5
Last change on this file since 63e2ca1b was 63e2ca1b, checked in by Sebastian Huber <sebastian.huber@…>, on 10/31/16 at 08:13:35

score: Simplify yield and unblock scheduler ops

Update #2556.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Unblocks a Thread from the Queue
5 *
6 * @ingroup ScoreScheduler
7 */
8
9/*
10 *  Copyright (C) 2011 Petr Benes.
11 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
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/score/schedulercbsimpl.h>
23#include <rtems/score/scheduleredfimpl.h>
24#include <rtems/score/schedulerimpl.h>
25#include <rtems/score/threadimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28Scheduler_Void_or_bool _Scheduler_CBS_Unblock(
29  const Scheduler_Control *scheduler,
30  Thread_Control          *the_thread,
31  Scheduler_Node          *node
32)
33{
34  Scheduler_CBS_Node   *the_node;
35  Scheduler_CBS_Server *serv_info;
36  Priority_Control      priority;
37  bool                  prepend_it;
38
39  the_node = _Scheduler_CBS_Node_downcast( node );
40  serv_info = the_node->cbs_server;
41  priority = _Scheduler_Node_get_priority( &the_node->Base.Base, &prepend_it );
42  (void) prepend_it;
43
44  /*
45   * Late unblock rule for deadline-driven tasks. The remaining time to
46   * deadline must be sufficient to serve the remaining computation time
47   * without increased utilization of this task. It might cause a deadline
48   * miss of another task.
49   */
50  if ( serv_info != NULL && ( priority & SCHEDULER_EDF_PRIO_MSB ) == 0 ) {
51    time_t deadline = serv_info->parameters.deadline;
52    time_t budget = serv_info->parameters.budget;
53    uint32_t deadline_left = the_thread->cpu_time_budget;
54    Priority_Control budget_left = priority - _Watchdog_Ticks_since_boot;
55
56    if ( deadline * budget_left > budget * deadline_left ) {
57      Thread_queue_Context queue_context;
58
59      /* Put late unblocked task to background until the end of period. */
60      _Thread_queue_Context_clear_priority_updates( &queue_context );
61      _Scheduler_CBS_Cancel_job(
62        scheduler,
63        the_thread,
64        the_node->deadline_node,
65        &queue_context
66      );
67    }
68  }
69
70  _Scheduler_EDF_Unblock( scheduler, the_thread, &the_node->Base.Base );
71  SCHEDULER_RETURN_VOID_OR_BOOL;
72}
Note: See TracBrowser for help on using the repository browser.