source: rtems/cpukit/score/src/schedulercbsunblock.c @ b8f76fa

5
Last change on this file since b8f76fa was b8f76fa, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 9, 2016 at 2:55:50 PM

score: Delete unused _Scheduler_Priority_compare()

By convention, thread priorities must be integers in RTEMS. Smaller
values represent more important threads.

  • Property mode set to 100644
File size: 2.7 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_thread _Scheduler_CBS_Unblock(
29  const Scheduler_Control *scheduler,
30  Thread_Control          *the_thread
31)
32{
33  Scheduler_CBS_Node   *node = _Scheduler_CBS_Thread_get_node( the_thread );
34  Scheduler_CBS_Server *serv_info = node->cbs_server;
35  Priority_Control      new_priority;
36
37  _Scheduler_EDF_Enqueue( scheduler, the_thread );
38  /* TODO: flash critical section? */
39
40  /*
41   * Late unblock rule for deadline-driven tasks. The remaining time to
42   * deadline must be sufficient to serve the remaining computation time
43   * without increased utilization of this task. It might cause a deadline
44   * miss of another task.
45   */
46  if (serv_info) {
47    time_t deadline = serv_info->parameters.deadline;
48    time_t budget = serv_info->parameters.budget;
49    time_t deadline_left = the_thread->cpu_time_budget;
50    time_t budget_left = the_thread->real_priority -
51                           _Watchdog_Ticks_since_boot;
52
53    if ( deadline*budget_left > budget*deadline_left ) {
54      /* Put late unblocked task to background until the end of period. */
55      new_priority = the_thread->Start.initial_priority;
56      the_thread->real_priority = new_priority;
57      if ( the_thread->current_priority != new_priority ) {
58        the_thread->current_priority = new_priority;
59        _Scheduler_EDF_Change_priority(
60          scheduler,
61          the_thread,
62          new_priority,
63          true
64        );
65      }
66    }
67  }
68
69  /*
70   *  If the thread that was unblocked is more important than the heir,
71   *  then we have a new heir.  This may or may not result in a
72   *  context switch.
73   *
74   *  Normal case:
75   *    If the current thread is preemptible, then we need to do
76   *    a context switch.
77   *  Pseudo-ISR case:
78   *    Even if the thread isn't preemptible, if the new heir is
79   *    a pseudo-ISR system task, we need to do a context switch.
80   */
81  if (
82    _Scheduler_EDF_Priority_compare(
83      the_thread->current_priority,
84      _Thread_Heir->current_priority
85    ) == 1 
86  ) {
87    _Scheduler_Update_heir(
88      the_thread,
89      the_thread->current_priority == PRIORITY_PSEUDO_ISR
90    );
91  }
92
93  SCHEDULER_RETURN_VOID_OR_NULL;
94}
Note: See TracBrowser for help on using the repository browser.